Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
KandS
Starting Member
1 Post |
Posted - 2014-10-12 : 08:31:52
|
I have a table which holds temperature data which is recorded every minute, it has the following fieldsdate (type Date)time (type Time)temp1 (type float)Example data would be2014-10-12, 00:00:00, 19.872014-10-12, 00:01:00, 20.252014-10-12, 00:02:00, 18.41etc etc so there is 1440 records per dayI can use the following to return the data logged every 15 minutes SELECT * FROM test1 WHERE date = '2014-10-12' GROUP BY UNIX_TIMESTAMP(time) DIV 900This returns me 4 points per hour but what I want is the average of the data in each of the 15 minute periods |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2014-10-12 : 13:43:44
|
This looks very much like MySQL question, which would be better answered in MySQL forum (This is MSSQL server forum).However, this might help you along:select `date` ,date_add(convert('00:00:00',time),interval floor((hour(`time`)*60+minute(`time`))/15)*15 minute) as `time` ,avg(temp1) as temp1 from temperature group by `date` ,floor((hour(`time`)*60+minute(`time`))/15) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-10-13 : 06:04:00
|
GROUP BY DATEDIFF(MINUTE, '19000101', Col1) / 15 Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
|
|
|
|
|