Santosh's profileSantosh KumarPhotosBlogListsMore ![]() | Help |
SQL Server, Splitting rows into columnsThink of a situation where you want your records to display in three columns so that it will get fit into one third number of rows. In oracle rownum keyword can be useful, but in SQL Server it requires additional logic. Think of the following data where you don’t have ID column INPUT TABLE ID NAME AGE SEX 1 N1 20 M 2 N2 21 M 3 N3 21 M 4 N4 21 M 5 N5 21 M 6 N6 21 M 7 N7 36 M 8 N8 26 M 9 N9 25 M 10 N10 22 M 11 N11 23 M 12 N12 22 M 13 N13 33 M 14 N14 23 M OUTPUT FORMAT ID NAME AGE SEX ID NAME AGE SEX ID NAME AGE SEX 1 N1 20 M 2 N2 21 M 3 N3 21 M 4 N4 21 M 5 N5 21 M 6 N6 21 M 7 N7 36 M 8 N8 26 M 9 N9 25 M 10 N10 22 M 11 N11 23 M 12 N12 22 M 13 N13 33 M 14 N14 23 M AND THE QUERY IS... select identity(int, 1,1) rn, a.* into #tmp from anytable a select * from (select * from #tmp a where rn%3=1) t1, (select * from #tmp b where rn%3=2) t2, (select * from #tmp c where rn%3=0) t3 where (t1.rn+1)=*t2.rn and (t2.rn+1)*=t3.rn drop table #tmp In Oracle it would look like below query...
select * from
(select * from anytable where mod(id,3)=1) t1, (select * from anytable where mod(id,3)=2) t2, (select * from anytable where mod(id,3)=0) t3 where (t1.id+1)=t2.id(+) and (t2.id+1)=t3.id(+) or it would be...
select * from (select * from anytable where mod(id-1,3)=0) t1, (select * from anytable where mod(id-2,3)=0) t2, (select * from anytable where mod(id-3,3)=0) t3 where (t1.id+1)=t2.id(+) and (t2.id+1)=t3.id(+) »»»»»»» by Santosh Kumar ? Original @ http://santu4you.spaces.live.com ASP.NET, The Beauty Of Ajax TechnologyCreate the following three files to see the beauty of ajax technology. The following code is prepared by refering w3schools tutorials Published at their website http : //www.w3schools.com ---[ DemoPage.aspx ]---------------------------------------- <html> <head> <script src="JScriptOne.js"></script> </head> <body ms_positioning="GridLayout"> First Name:<br> <input type="text" id="txt1" onkeyup="showHint(this.value)"> <span id="txtHint"></span> </body> </html> ---[ JScriptOne.js ]---------------------------------------- var xmlHttp; function showHint(str){ if (str.length==0){ document.getElementById("txtHint").innerHTML=""; return; } xmlHttp=GetXmlHttpObject(); if (xmlHttp==null){ alert ("Your browser does not support AJAX!"); return; } var url="gethint.aspx?q="+str&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged(){ if (xmlHttp.readyState==4){ document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject(){ var xmlHttp=null; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } ---[ GetHint.aspx ]----------------------------------------- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Response.Expires = -1 Dim a(30), q, hint, i a(1) = "Anna" a(2) = "Brittany" a(3) = "Cinderella" a(4) = "Diana" a(5) = "Eva" a(6) = "Fiona" a(7) = "Gunda" a(8) = "Hege" a(9) = "Inga" a(10) = "Johanna" a(11) = "Kitty" a(12) = "Linda" a(13) = "Nina" a(14) = "Ophelia" a(15) = "Petunia" a(16) = "Amanda" a(17) = "Raquel" a(18) = "Cindy" a(19) = "Doris" a(20) = "Eve" a(21) = "Evita" a(22) = "Sunniva" a(23) = "Tove" a(24) = "Unni" a(25) = "Violet" a(26) = "Liza" a(27) = "Elizabeth" a(28) = "Ellen" a(29) = "Wenche" a(30) = "Vicky" q = UCase(Request.QueryString("q")) If Len(q) > 0 Then hint = "" For i = 1 To 30 If q = UCase(Mid(a(i), 1, Len(q))) Then hint = hint & "<tr><td>" & a(i) & "</td></tr>" End If Next End If If hint = "" Then Response.Write("no suggestion") Else Response.Write("<table border=1 width=150>" & hint & "</table>") End If End Sub »»»»»»» by Santosh Kumar ? Original @ http://santu4you.spaces.live.com Short Story ... MommyOnce upon a time there was a child ready to be born. So one day he asked God: "How am I going to live on earth being so small and helpless?" God replied, "Among the many angels, I chose one for you. She will be waiting for you and will take care of you." "But tell me, here in Heaven, I don't do anything else but sing and smile, that's enough for me to be happy." "Your angel will sing for you and will also smile for you every day. And you will feel your angel's love and be happy." "And how am I going to be able to understand when people talk to me, if I don't know the language that men talk?" "Your angel will tell you the most beautiful and sweet words you will ever hear, and with much patience and care, your angel will teach you how to speak." "And what am I going to do when I want to talk to you?" "Your angel will place your hands together and will teach you how to pray." "I've heard that on earth there are bad men. Who will protect me?" "Your angel will defend you even if it means risking its life." "But I will always be sad because I will not see you anymore." "Your angel will always talk to you about me and will teach you the way for you to come back to me, even though I will always be next to you." At that moment there was much peace in Heaven, but voices from earth could already be heard, and the child in a hurry asked softly: "Oh God, if I am about to leave now, please tell me my angel's name." "Your angel's name is of no importance, you will call your angel: Mommy." The Twelve Gifts of BirthOnce upon a time, a long time ago, when princes and princesses lived in faraway kingdoms, royal children were given twelve special gifts when they were born. You may have heard the stories. Twelve wise women of the kingdom, or fairy godmothers as they were often called, traveled swiftly to the castle whenever a new prince or princess came into the world. Each fairy godmother pronounced a noble gift upon the royal baby. As time went on, the wise women came to understand that the twelve royal gifts of birth belong to every child, born anywhere at anytime. They yearned to proclaim the gifts to all children, but the customs of the land did not allow that. One day when the wise women gathered together they made this prophecy: Some day, all the children of the world will learn the truth about their noble inheritance. When that happens a miracle will unfold on the kingdom of Earth. Some day is near. Here is the secret they want you to know. At the wondrous moment you were born, as you took your first breath, a great celebration was held in the heavens and twelve magnificent gifts were granted to you. The first gift is STRENGTH. May you remember to call upon it whenever you need it. The second gift is BEAUTY. May your deeds reflect its depth. The third gift is COURAGE. May you speak and act with confidence and use courage to follow your own path. The fourth gift is COMPASSION. May you be gentle with yourself and others. May you forgive those who hurt you and yourself when you make mistakes. The fifth gift is HOPE. Through each passage and season, may you trust the goodness of life. The sixth gift is JOY. May it keep your heart open and filled with light. The seventh gift is TALENT. May you discover your own special abilities and contribute them toward a better world. The eighth gift is IMAGINATION. May it nourish your visions and dreams. The ninth gift is REVERENCE. May you appreciate the wonder that you are and the miracle of all creation. The tenth gift is WISDOM. Guiding your way, wisdom will lead you through knowledge to understanding. May you hear its soft voice. The eleventh gift is LOVE. It will grow each time you give it away. The twelfth gift is FAITH. May you believe. Now you know about your twelve gifts of birth. But there is more to the secret that the wise women knew. Use your gifts well and you will discover others, among them a gift that is uniquely you. See these noble gifts in other people. Share the truth and be ready for the miracle to unfold as the prophecy of the wise women comes true. Short Story ... The StarfishAn old man was walking along the beach, when he came upon a part of the sand where thousands of starfish had washed ashore. A little further down the beach he saw a young woman, who was picking up the starfish one at a time and tossing them back into the ocean. "Oh you silly girl," he exclaimed. "You can't possibly save all of these starfish. There's too many." The woman smiled and said, "I know. But I can save this one, " and she tossed another into the ocean, "and this one", toss, "and this one..." Short Story ... Cupcakes and RootbeerThere once was a little boy who wanted to meet God. He knew it was a long trip to where God lived, so he packed his suitcase with cupcakes, several cans of root beer and started on his journey. When he had gone about three blocks, he saw an elderly woman. She was sitting on a park bench watching the pigeons. The boy sat down next to her and opened his suitcase. He was about to take a drink from his root beer when he noticed the lady looked hungry so he offered her a cupcake. She gratefully accepted and smiled at him. Her smile was so wonderful that he wanted to see it again, so he offered a root beer as well. Once again she smiled at him. The boy was delighted! They sat there all afternoon eating and smiling without saying a word. As it began to grow dark, the boy realized how tired he was and wanted to go home. He got up to leave but before he had gone no more than a few steps, he turned around and ran back to the old woman, giving her a big hug. She gave him her biggest smile ever. When the boy arrived home his Mother was surprised by the look of joy on his face. She asked, "What has made you so happy today?" He replied, "I had lunch with God." Before his mother could respond he added, "You know what? She's got the most beautiful smile in the whole world!" Meanwhile, the old woman, also radiant with joy, returned to her home. Her son was stunned by the look of peace on her face. He asked, "Mother, what has made you so happy today?" She replied, "I ate cupcakes in the park with God." And before her son could reply, she added, "You know, he is much younger than I expected." Too often we underestimate the power of a touch, a smile, a kind word, a listening ear, an honest compliment, or the smallest act of caring; all of which have the potential to turn a life around. People come into our lives for a reason, a season, or a lifetime. Take no one for granted and embrace all equally with joy! Short Story ... The Carpenter's HouseAn elderly carpenter was ready to retire. He told his employer-contractor of his plans to leave the house building business and live a more leisurely life with his wife enjoying his extended family. He would miss the paycheck, but he needed to retire. They could get by. The contractor was sorry to see his good worker go and asked if he could build just one more house as a personal favor. The carpenter said yes, but in time it was easy to see that his heart was not in his work. He resorted to shoddy workmanship and used inferior materials. It was an unfortunate way to end his career. When the carpenter finished his work and the builder came to inspect the house, the contractor handed the front-door key to the carpenter. "This is your house," he said, "my gift to you." What a shock! What a shame! If he had only known he was building his own house, he would have done it all so differently. Now he had to live in the home he had built none too well. So it is with us. We build our lives in a distracted way, reacting rather than acting, willing to put up less than the best. At important points we do not give the job our best effort. Then with a shock we look at the situation we have created and find that we are now living in the house we have built. If we had realized that we would have done it differently. Think of yourself as the carpenter. Think about your house. Each day you hammer a nail, place a board, or erect a wall. Build wisely. It is the only life you will ever build. Even if you live it for only one day more, that day deserves to be lived graciously and with dignity. The plaque on the wall says, "Life is a do-it-yourself project." Your life tomorrow will be the result of your attitudes and the choices you make today. Short Story ... Hospital WindowsTwo men, both seriously ill, occupied the same hospital room. One man was allowed to sit up in his bed for an hour each afternoon to help drain the fluid from his lungs. His bed was next to the room's only window. The other man had to spend all his time flat on his back. The men talked for hours on end. They spoke of their wives and families, their homes, their jobs, their involvement in the military service, where they had been on vacation. And every afternoon when the man in the bed by the window could sit up, he would pass the time by describing to his roommate all the things he could see outside the window. The man in the other bed began to live for those one-hour periods where his world would be broadened and enlivened by all the activity and color of the world outside. The window overlooked a park with a lovely lake. Ducks and swans played on the water while children sailed their model boats. Young lovers walked arm in arm amidst flowers of every color of the rainbow. Grand old trees graced the landscape, and a fine view of the city skyline could be seen in the distance. As the man by the window described all this in exquisite detail, the man on the other side of the room would close his eyes and imagine the picturesque scene. One warm afternoon the man by the window described a parade passing by. Although the other man couldn't hear the band - he could see it in his mind's eye as the gentleman by the window portrayed it with descriptive words. Days and weeks passed. One morning, the day nurse arrived to bring water for their baths only to find the lifeless body of the man by the window, who had died peacefully in his sleep. She was saddened and called the hospital attendants to take the body away. As soon as it seemed appropriate, the other man asked if he could be moved next to the window. The nurse was happy to make the switch, and after making sure he was comfortable, she left him alone. Slowly, painfully, he propped himself up on one elbow to take his first look at the world outside. Finally, he would have the joy of seeing it for himself. He strained to slowly turn to look out the window beside the bed. It faced a blank wall. The man asked the nurse what could have compelled his deceased roommate who had described such wonderful things outside this window. The nurse responded that the man was blind and could not even see the wall. She said, "Perhaps he just wanted to encourage you." Short Story ... PerspectivesOne day a father and his rich family took his young son on a trip to the country with the firm purpose to show him how poor people can be. They spent a day and a night in the farm of a very poor family. When they got back from their trip the father asked his son, "How was the trip?" Very good, Dad!" "Did you see how poor people can be?" the father asked. "Yeah!" "And what did you learn?" The son answered, "I saw that we have a dog at home, and they have four. We have a pool that reaches to the middle of the garden, they have a creek that has no end. We have imported lamps in the garden, they have the stars. Our patio reaches to the front yard, they have a whole horizon." When the little boy was finishing, his father was speechless. His son added, "Thanks, Dad, for showing me how poor we are!" Isn't it true that it all depends on the way you look at things? If you have love, friends, family, health, good humor and a positive attitude toward life, you've got everything! You can't buy any of these things. You can have all the material possessions you can imagine, provisions for the future, etc., but if you are poor of spirit, you have nothing! Short Story ... Self AppraisalA little boy went into a drug store, reached for a soda carton and pulled it over to the telephone. He climbed onto the carton so that he could reach the buttons on the phone and proceeded to punch in seven digits (phone numbers). The store-owner observed and listened to the conversation: Boy: "Lady, Can you give me the job of cutting your lawn? Woman: (at the other end of the phone line): "I already have someone to cut my lawn." Boy: "Lady, I will cut your lawn for half the price of the person who cuts your lawn now." Woman: I'm very satisfied with the person who is presently cutting my lawn. Boy: (with more perseverance) : "Lady, I'll even sweep your curb and your sidewalk, so on Sunday you will have the prettiest lawn in all of Palm beach , Florida." Woman: No, thank you. With a smile on his face, the little boy replaced the receiver. The store-owner, who was listening to all this, walked over to the boy. Store Owner: "Son... I like your attitude; I like that positive spirit and would like to offer you a job." Boy: "No thanks, Store Owner: But you were really pleading for one. Boy: No Sir, I was just checking my performance at the job I already have. I am the one who is working for that lady I was talking to!" This is what we call "Self Appraisal" Short Story ... I Would Pick More DaisiesWhen the late Nadine Stair of Louisville, Kentucky, was 85 years old, she was asked what she would do if she had her life to live over again. "I'd make more mistakes next time," she said. "I'd relax. I would limber up. I would be sillier than I have been on this trip. I would take fewer things seriously. I would take more chances. I would climb more mountains and swim more rivers. I would eat more ice cream and less beans. I would perhaps have more actual troubles, but I'd have fewer imaginary ones. "You see, I'm one of those people who live sensibly and sanely hour after hour, day after day. Oh, I've had my moments, and if I had to do it over again, I'd have more of them. In fact, I'd try to have nothing else. Just moments, one after another, instead of living so many years ahead of each day. I've been one of those persons who never goes anywhere without a thermometer, a hot water bottle, and a raincoat. If I had to do it over again, I would travel lighter than I have. "If I had my life to live over, I would start barefoot earlier in the spring and stay that way later in the fall. I would go to more dances. I would ride more merry-go-rounds and I would pick more daisies." What Will MatterReady or not, some day it will all come to an end. There will be no more sunrises, no minutes, hours or days. All the things you collected, whether treasured or forgotten will pass to someone else. Your wealth, fame and temporal power will shrivel to irrelevance. It will not matter what you owned or what you were owed. Your grudges, resentments, frustrations and jealousies will finally disappear. So too, your hopes, ambitions, plans and to do lists will expire. The wins and losses that once seemed so important will fade away. It won't matter where you came from or what side of the tracks you lived on at the end. It won't matter whether you were beautiful or brilliant. Even your gender and skin color will be irrelevant. So what will matter? How will the value of your days be measured? What will matter is not what you bought but what you built, not what you got but what you gave. What will matter is not your success but your significance. What will matter is not what you learned but what you taught. What will matter is every act of integrity, compassion, courage, or sacrifice that enriched, empowered or encouraged others to emulate your example. What will matter is not your competence but your character. What will matter is not how many people you knew, but how many will feel a lasting loss when you're gone. What will matter is not your memories but the memories that live in those who loved you. What will matter is how long you will be remembered, by whom and for what. Living a life that matters doesn't happen by accident. It's not a matter of circumstance but of choice. Choose to live a life that matters. Always Aim HigherAlways aim higher than you believe you can reach. So often, you'll discover that when your talents are set free by your imagination, you can achieve any goal. If people offer their help or wisdom as you go through life, accept it gratefully. You can learn much from those who have gone before you. But never be afraid or hesitant to step off the accepted path and head off in your own direction if your heart tells you that it's the right way for you. Always believe that you will ultimately succeed at whatever you do, and never forget the value of persistence, discipline, and determination. You are meant to be whatever you dream of becoming. Short Story ... The Seven Wonders of the WorldJunior high school students in Chicago were studying the Seven Wonders of the World. At the end of the lesson, the students were asked to list what they considered to be the Seven Wonders of the World. Though there was some disagreement, the following received the most votes: 1. Egypt's Great Pyramids 2. The Taj Mahal in India 3. The Grand Canyon in Arizona 4. The Panama Canal 5. The Empire State Building 6. St. Peter's Basilica 7. China's Great Wall While gathering the votes, the teacher noted that one student, a quiet girl, hadn't turned in her paper yet. So she asked the girl if she was having trouble with her list. The quiet girl replied, "Yes, a little. I couldn't quite make up my mind because there were so many." The teacher said, "Well, tell us what you have, and maybe we can help." The girl hesitated, then read, "I think the Seven Wonders of the World are: 1. to touch... 2. to taste... 3. to see... 4. to hear... .......... (She hesitated a little, and then added...) 5. to feel... 6. to laugh... 7. and to love. The room was so quiet, you could have heard a pin drop. May this story serve as a gentle reminder to all of us that the things we overlook as simple and ordinary are often the most wonderful - and we don't have to travel anywhere special to experience them. Enjoy your gifts! The Thirty Second QuizDon't bother getting a pen and paper... just read... if you can't answer them, just keep going. 1. Name the five wealthiest people in the world. 2. Name the last five Heisman trophy winners. 3. Name the last five winners of the Miss America contest. 4. Name ten people who have won the Nobel or Pulitzer prize. 5. Name the last five Academy Award winners for Best Actor and Actress. How did you do? The point is, none of us remembers the headliners of yesterday. These are no second-rate achievers. They're the best in their fields. But the applause dies. Awards tarnish. Achievements are forgotten. Accolades and certificates are buried with their owners. Now here's another quiz. See how you do on this one: 1. Name three teachers who aided your journey through school. 2. Name three friends who helped you through a difficult time. 3. Name five people who have taught you something worth while. 4. Think of a few people who have made you feel appreciated and special. 5. Think of five people you enjoy spending time with. Easier? The lesson? The people who make a difference in your life aren't the ones with the most credentials, the most money, or the most awards. They're the ones who care. Short Story ... The Precious GiftOnce upon a time, when God had finished making the world, he wanted to leave behind a piece of His own divinity, a spark of His essence, a promise to man of what he could become, with effort. He looked for a place to hide this precious gift because, He explained, what man could find too easily would never be valued by him. "Then you must hide this gift on the highest mountain peak on earth," said one of his counselors. God shook His head, "No, for man is an adventuresome creature and he will soon enough learn to climb the highest mountain peaks." "Hide it then, O Great One, in the depths of the earth." "I think not," said God. "for man will one day discover that he can dig into the deepest parts of the earth." "In the middle of the ocean then, Master?" God shook His head. "I've given man a brain, you see, and one day he'll learn to build ships and cross the mightiest oceans." "Where then, Master?" cried His counselors. God smiled, "I'll hide it where every man and woman will be able to find it if they look sincerely and deeply enough. I'll hide it in their heart." Short Story ... Two WolvesA native American grandfather was talking to his grandson about how he felt. He said "I feel as if I have two wolves fighting in my heart. One wolf is the vengeful, angry, violent one. The other wolf is the loving, compassionate one." The grandson asked him, which wolf will win the fight in your heart? The grandfather answered: "The one I feed." Set Yourself FreeSet yourself free from anything that might hinder you in becoming the person you want to be. Free yourself from the uncertainties about your abilities or the worth of your dreams, from the fears that you may not be able to achieve them or that they won't be what you wanted. Set yourself free from the past. The good things from yesterday are still yours in memory; the things you want to forget you will, for tomorrow is only a sunrise away. Free yourself from regret or guilt, and promise to live this day as fully as you can. Set yourself free from the expectations of others, and never feel guilty or embarrassed if you do not live up to their standards. You are most important to yourself; live by what you feel is best and right for you. Others will come to respect your integrity and honesty. Set yourself free to simply be yourself, and you will soar higher than you've ever dreamed. Short Story ... Paid In FullA little boy came up to his mother in the kitchen one evening while she was fixing supper, and he handed her a piece of paper that he had been writing on. After his mom dried her hands on an apron, she read it, and this is what it said: For cutting the grass: $5.00 For cleaning up my room this week: $1.00 For going to the store for you: .50 Baby-sitting my kid brother while you went shopping: .25 Taking out the garbage: $1.00 For getting a good report card: $5.00 For cleaning up and raking the yard: $2.00 Total owed: $14.75 Well, his mother looked at him standing there, and the boy could see the memories flashing through her mind. She picked up the pen, turned over the paper he'd written on, and this is what she wrote: "For the nine months I carried you while you grew inside me: No Charge. For all the nights that I've sat up with you, doctored and prayed for you: No Charge. For all the trying times, and all the tears that you've caused through the years: No Charge. For all the nights that were filled with dread, and for the worries I knew were ahead: No Charge. For the toys, food, clothes, and even wiping your nose: No Charge. When you add it up, Son, the cost of my love is: No Charge." When the boy finished reading what his mother had written, there were big tears in his eyes, and he looked straight up at his mother and said, "Mom, I sure do love you." And then he took the pen and in great big letters he wrote: "PAID IN FULL The Greatest WonderIf the Earth were only a few feet in diameter, floating a few feet above a field somewhere, people would come from everywhere to marvel at it. People would walk around it marveling at its big pools of water, its little pools and the water flowing between the pools. People would marvel at the very thin layer of gas surrounding it and the water suspended in the gas. The people would marvel at all the creatures walking around the surface of the ball, and at the creatures in the water. The people would declare it as sacred because it was the only one, and they would protect it so that it would not hurt. The ball would be the greatest wonder known, and people would come to pray to it, to be healed, to gain knowledge, to know beauty and to wonder how it could be. People would love it, and defend it with their lives because they would somehow know that their lives, their own roundness, could be nothing without it. If the Earth were only a few feet in diameter |
|
|