RIAS
asked on
Combine two sql queries
Hi,
I have 2 queries ,any help on how to combine them will be appreciated
Specification for the query :
Where [Status] at %Input_Date% = “Active” or “Preserved Pensioner” or “Pensioner” or “Widow(er)” or “Child” ---is it the latest entry
OR where [Status] at %Input_Date% = “No Liability”
and [Dateleft], [Dbdate], [Pdpencomm] or [Topaid] later than (%Input_Date% less 1 Year)
Query1:
Select * From Personal_Details where PERSONAL_DETAILS.CURRSTATU S = 'PRESERVED PENSIONER' and DateJS > datejc
Query2:
select * from Personal_Details a inner join DEATH_BENEFIT b on a.REFNO=b.REFNO inner join PENSIONER_DETAIL c on c.REFNO=a.REFNO inner join TRANSFER_OUT_HISTORY d on d.REFNO=a.REFNO where (a.CURRStatus in ('Active','PreservedPensio ner','Pens ioner','Wi dow','Chil d','No Liability')) and (a.Dateleft > dateadd(y,17/06/2011,-1)) or b.dbdate > dateadd(y,17/06/2011,-1) or c.pdpencomm > dateadd(y,17/06/2011,-1) or d.topaid > dateadd(y,17/06/2011,-1)
I have 2 queries ,any help on how to combine them will be appreciated
Specification for the query :
Where [Status] at %Input_Date% = “Active” or “Preserved Pensioner” or “Pensioner” or “Widow(er)” or “Child” ---is it the latest entry
OR where [Status] at %Input_Date% = “No Liability”
and [Dateleft], [Dbdate], [Pdpencomm] or [Topaid] later than (%Input_Date% less 1 Year)
Query1:
Select * From Personal_Details where PERSONAL_DETAILS.CURRSTATU
Query2:
select * from Personal_Details a inner join DEATH_BENEFIT b on a.REFNO=b.REFNO inner join PENSIONER_DETAIL c on c.REFNO=a.REFNO inner join TRANSFER_OUT_HISTORY d on d.REFNO=a.REFNO where (a.CURRStatus in ('Active','PreservedPensio
ASKER
Hi,
Got error :
Msg 102, Level 15, State 1, Line 14
Incorrect syntax near ')'.
Thanks
Got error :
Msg 102, Level 15, State 1, Line 14
Incorrect syntax near ')'.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers mate
you are very welcome glad I could help
happy coding :-)
happy coding :-)
Open in new window