sql - Compare the date from other table -
using sql sever 2005
table1
id startdate enddate 001 02/23/2010 07/22/2010 002 05/03/2010 null 003 02/02/2011 null ... table2
date
02/24/2011 02/25/2011 ... ... condition
- if
enddatenot nullstartdatecompare max(date) table2, if startdate > 6 month should display "expired"
how make query above condition.
need query help.
select startdate, [status]=case when datediff(m,startdate,(select max(date) table2))>6 'expired' else 'valid' end table1 enddate not null
Comments
Post a Comment