Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello...

i have a table named pointdb containing SOLAR_ACTIVE_POWER_G_VAL0,LOAD_ACTIVE_POWER_G_VAL0, timestamp columns. it contains every second wise data. i wanted to display max of SOLAR_ACTIVE_POWER_G_VAL0 and max of LOAD_ACTIVE_POWER_G_VAL0 occurred within every 10 minute of intereval. for that i have written a query as follows

SQL
SELECT max(SOLAR_ACTIVE_POWER_G_VAL0) AS Solar,max(LOAD_ACTIVE_POWER_G_VAL0) AS Load, (DATEPART(MINUTE, [timestamp]) % 10) AS [Minutes]
FROM pointdb WHERE CONVERT(varchar,[timestamp],101) in('03/07/2014')
GROUP BY (DATEPART(MINUTE, [timestamp]) % 10)


but it is not giving right output.
plz give me right solution.
Posted

1 solution

(DATEPART(MINUTE, [timestamp]) % 10) will be the same for any hour of the day. That means, you have to get the hour into that value somehow. I'd suggest to use
(DATEPART(HOUR, [timestamp]) * 10 + DATEPART(MINUTE, [timestamp]) % 10)

(both in SELECT and GROUP BY).
 
Share this answer
 
Comments
TAUSEEF KALDANE 11-Mar-14 5:52am    
it gives only minute wise data. It should give data occurred whithin 10 minutes of interval

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900