如
date value
2012-11-18 13
2012-11-17 11
2012-11-16 14
2012-11-15 16
2012-11-14 18
2012-11-13 12
2012-11-12 19
...
2012-09-20 8
2012-09-19 5
2012-09-18 16 ------最佳解决方案-------------------- if exists(select * from tb as a where date between getdate()-7 and getdate()
and not exists(select * tb where value<a.value))
select 'yes'
else
select 'no' ------其他解决方案-------------------- if (select min(value) from TB)=(select min(value) from TB where [date]>dateadd(day,-7,getdate())
select 'YES'
else
select 'NO’ ------其他解决方案--------------------
IF EXISTS (SELECT *
FROM tb AS a
WHERE DATE BETWEEN Dateadd(DAY,-7,Getdate())
AND Getdate()
AND NOT EXISTS (SELECT *
FROM tb
WHERE VALUE < a.VALUE))
PRINT 'yes'
ELSE
PRINT 'no'
------其他解决方案--------------------
select
top 1 * from test where datediff(dd,[date],getdate()) between 0 and 7
and [value]=(select min([value]) from test)
order by [value] asc