What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 7653 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > using CASE (Transact-SQL) ...
Syedshakeer

using CASE (Transact-SQL)

 Code Snippet posted by: Syedshakeer | Posted on: 2/22/2010 | Category: SQL Server Codes | Views: 1538 | Status: [Member] | Alert Moderator   


Write a Query to dispaly the data from a Table when 'M' as 'MALE' and 'F' as 'FEMALE ?

ID Name Gender

1 AAA M
2 BBB F
3 CCC F

Ans)
select name,
Gender=case Gender when 'M' then 'MALE'
when 'F' then 'FEMALE'
end
from table_name

OutPut:-


Name Gender

AAA MALE
BBB FEMALE
CCC FEMALE

Syed Shakeer Hussain
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 5:11:50 PM