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 Query

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2011-05-10 : 07:06:07
Hi,

I want to add a condition to my select query but I dont know how to do it any help please..

The select query is

select * from dbo.PatientData_151
where tod is null and regstat <> '99'


Now, I have a field called yob (year of birth) which on the table is for example 153, but to get the exact yob = 153 + 1800 = 1953

Now I have another field called lcd which is static as 2010.

I want to include the condition;

if the yob (please add 1800 to yob to make it the exact yob) is more than a 115 years prior to the lcd - output result

Thanks

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-05-10 : 07:14:54
select * from dbo.PatientData_151
where tod is null and regstat <> '99'
AND lcd-(yob+1800)>115




--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2011-05-10 : 07:20:13
thanks
Go to Top of Page
   

- Advertisement -