select * from 表 a where fyear=2003 and fmonth=2 and
not exists(select 1 from 表 where fyear=2003 and fmonth=1 and a.fbillid=fbillid and a.fempid=fempid)
not exists(select 1 from 表 where fyear=2003 and fmonth=1 and a.fbillid=fbillid and a.fempid=fempid)
insert @ values(2003, 1, 1 , 1)
insert @ values(2003, 1, 2, 1)
insert @ values(2003 , 1, 3 , 1)
insert @ values(2003 , 1, 4 , 1 )
insert @ values(2003 , 2, 1 , 1)
insert @ values(2003 , 2, 2 , 1)
select * from @ a where fyear=2003 and fmonth=1 and not exists(select 1 from @ where fyear=2003 and fmonth=2 and a.fbillid=fbillid and a.fempid=fempid)--还是:select * from @ a where fyear=2003 and fmonth=2 and not exists(select 1 from @ where fyear=2003 and fmonth=1 and a.fbillid=fbillid and a.fempid=fempid)