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
 Import look up

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-06-08 : 05:52:23
Hi,

I have the following select statement which works fine.

SELECT     DISTINCT 
TOP (100) PERCENT t2.goldpracid, t2.goldpatid, t2.vision_patid,t2.yob, t2.mob, t2.gender, t1.prac_no, t1.goldpracid as goldpracid2, t1.prac_eid, t3.goldPatID AS Importgoldpatid
FROM GPRDData.dbo.tblpatdetails AS t2 INNER JOIN
Verisis.dbo.tblImport AS t3 ON t2.goldpatid = t3.goldpatid INNER JOIN
GPRDTech.gprdsql.TblPracDetails AS t1 ON t2.goldpracid = t1.goldpracid
Order BY Importgoldpatid



t2.gender is stored as 1 or 2 in the GPRDData.dbo.tblpatdetails table.

1 = male
2 = Female

I want to change the select query above and instead of having at the output 1 or 2, I have instead male or female.

Any help pls

Many thanks

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-06-08 : 05:55:40
CASE WHEN t2.gender = 1 THEN 'male' WHEN 2 THEN 'female' ELSE 'whoknows' END AS Gender

Replace t2.gender in your query with the above..
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-08 : 06:12:30
WHEN 2 should be WHEN t2.gender = 2

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-06-08 : 06:15:51
Thanks
Go to Top of Page
   

- Advertisement -