C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to use Case in SQL


Posted Date: 23 May 2008    Resource Type: Code Snippets    Category: SQL

Posted By: Mahesh H Shivaswamy       Member Level: Silver
Rating:     Points: 3



Case in SQL queries are very usefull concept , this is like using switch statement in c and C++ programming.

Here is the sample query using cases in sql server,



select

case
when price is null then 'Not Yet Priced'

when price <10 then 'Below 10'

when price>=10 and price <=20 then 'price is between 10 to 20'

else 'price is above 20'

end

as 'Price Category',title FROM pubs.dbo.titles ORDER BY price











Responses

Author: Kapil Dhawan    17 Jun 2008Member Level: Gold   Points : 2
Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code is going to help lots of guys.
Ton Thanks to you
Regards,
Kapil



Author: Bunty    01 Jul 2008Member Level: Diamond   Points : 2
Hi,

Very nice piece of code.

Short and simple to understand.

Thanks for sharing your knowledge with us.

Keep posting such useful codes.

Thanks and Reagrds
S.S.Bajoria


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Case  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to format in Sql Server
Previous Resource: Copy Structure of a Table to a New Table
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

accuconference

Contact Us    Privacy Policy    Terms Of Use