Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select Problem

Author  Topic 

MGA
Starting Member

28 Posts

Posted - 2010-04-16 : 03:50:23
hi all;
i have a table named Periods has the following columns:
Period_Id int,
Period_Start_Date,
Period_End_Date,
Closed bit default('false')

i want to select the data in the table Periods
but i want the data in the column Closed take the values:
'Not Closed' if it = 0
'Has been Closed' if it = 1

Example
if the table data is
Period_Id Period_Start_Date Period_End_Date Closed
1 1/5/2010 31/5/2010 0
2 1/6/2010 30/6/2010 1

i want to select them in the form
Period_Id Period_Start_Date Period_End_Date Closed
1 1/5/2010 31/5/2010 Not Closed
2 1/6/2010 30/6/2010 Has been Closed




Regards

Sachin.Nand

2937 Posts

Posted - 2010-04-16 : 03:55:21
[code]
select period,Period_Start_Date,Period_End_Date, case Closed when 1 then 'Has been Closed' else 'Not Closed' end as Closed from Periods
[/code]

you can get more info on case statements here

http://msdn.microsoft.com/en-us/library/ms181765.aspx

PBUH
Go to Top of Page
   

- Advertisement -