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 Statement

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-06-23 : 08:30:42
Hi,

I have the following select query which works fine;
SELECT     TOP (100) PERCENT dbo.tblDuplicateData.ProjectID, dbo.tblDuplicateData.LoadRef AS Ref, dbo.tblDuplicateData.In_ImpFile AS Imported, 
dbo.tblDuplicateData.LoadDate, ISNULL(dbo.tblProjectPatients.PatCategory, 'No_Category') AS Category,
COUNT(dbo.tblProjectPatients.ProjectPatientID) AS Pats
FROM dbo.tblDuplicateData LEFT OUTER JOIN
dbo.tblProjectPatients ON dbo.tblDuplicateData.LoadRef = dbo.tblProjectPatients.LoadRef
GROUP BY dbo.tblDuplicateData.LoadRef, dbo.tblDuplicateData.In_ImpFile, dbo.tblDuplicateData.LoadDate, dbo.tblDuplicateData.ProjectID,
ISNULL(dbo.tblProjectPatients.PatCategory, 'No_Category')
ORDER BY dbo.tblDuplicateData.LoadDate, dbo.tblDuplicateData.ProjectID


Now, I have two fields in the table - dbo.tblProjectPatients (pat_eid & GOLDPatIDs. If pat_eids is populated then for that record GOLDPatIDs will be NULL and vice versa. There won't be any scenario where both will have values simultaneously.

Now, On the select statement I want to have an identifier column called IDENTIFIER where if GOLDPatIDs is Null then have a value False else have a value True.

Any help please.....

Thank you

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-23 : 08:34:25
Add this in your SELECT statement

case when GOLDPatIDs is null then 'False' else 'True' end as IDENTIFIER

Madhivanan

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

- Advertisement -