1.--
where HISDATA1.DDATE between DateSerial( [select top 1 Year( HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc],1,1)
and DateSerial([select top 1 Year(HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc],12,31)
2.--
SELECT HISDATA1.DDATE
FROM HISDATA1
where HISDATA1.DDATE between
DateAdd("yyyy",-10,DateSerial((select top 1 Year( HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc),1,1) )
and
DateAdd("yyyy",-10,DateSerial((select top 1 Year( HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc),12,31) )
order by HISDATA1.DDATE desc
where HISDATA1.DDATE between DateSerial( [select top 1 Year( HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc],1,1)
and DateSerial([select top 1 Year(HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc],12,31)
2.--
SELECT HISDATA1.DDATE
FROM HISDATA1
where HISDATA1.DDATE between
DateAdd("yyyy",-10,DateSerial((select top 1 Year( HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc),1,1) )
and
DateAdd("yyyy",-10,DateSerial((select top 1 Year( HISDATA1.DDATE) from HISDATA1 group by HISDATA1.DDATE order by HISDATA1.DDATE desc),12,31) )
order by HISDATA1.DDATE desc
No comments:
Post a Comment