SELECT [Id]
,[Date]
,[Condition]
FROM [CRESULTS]
where condition = 'abc'
我需要找到hour13的maxvalue和相应的日期,到目前为止我写的查询是有效的,但是还有其他任何改变的想法吗?
SELECT top 1 max(abs([Hour13])) as hour13,date
FROM CRESULTS where condition ='a' and Date between '2011-05-16' and '2011-07-10'
group date
order by hour13 desc
答案 0 :(得分:2)
此处您不需要MAX
。
SELECT TOP 1
ABS(hour13) AS abs_hour13,
datefield
FROM cresults
WHERE condition = 'a'
AND datefield BETWEEN '2011-05-16' AND '2011-07-10'
ORDER BY
abs_hour13 DESC