SQL select maximum from two time periods

Posted by HamishC on Stack Overflow See other posts from Stack Overflow or by HamishC
Published on 2010-04-26T02:57:08Z Indexed on 2010/04/26 3:03 UTC
Read the original article Hit count: 190

Filed under:
|

I have a query, Im trying to select the maximum value from the summer period (nov-april down here) but it only gives me values from nov-dec with this query. Any ideas why?

SELECT TOP 10 Value, DateTime 
  FROM history
 WHERE Tagname = @Tag
   AND 
       ((DateTime >= @StartYear AND DateTime < @StartWinter)
    OR 
       (DateTime >= @FinishWinter AND DateTime < @FinishYear))
ORDER BY Value DESC

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server