I need your help in following case.
i have table ChartData
in that table i have large number of records as per below
PK,ProjectID,MAchineId,Powervalue,PowerData
1 1 1 20.5 2011-07-05 12:00:00
2 1 1 21.5 2011-07-05 12:01:00
3 1 1 22.5 2011-07-05 12:02:00
4 1 1 23.5 2011-07-05 12:03:00
5 1 1 24.5 2011-07-05 12:04:00
6 1 1 25.5 2011-07-05 12:05:00
7 1 1 26.5 2011-07-05 12:06:00
8 1 1 27.5 2011-07-05 12:07:00
9 1 1 26.5 2011-07-05 12:08:00
10 1 1 28.5 2011-07-05 12:09:00
Output
PK,ProjectID,MAchineId,Powervalue(Avg value of power),PowerData
1 1 1 20.5 2011-07-05 12:00:00
6 1 1 25.5 2011-07-05 12:05:00
any help would be appreciated. thanks in advance.
I guess you want to aggregate every five tuples? If so, maybe something like this will help:
SELECT PK, ProjectID, MachineID, AVG(Powervalue), PowerData FROM table GROUP BY (PK-1)/5although I don’t really know if you can do that with GROUP BY
@gbn: I would like to answer to your comment directly, but I think I lack the privilege. Can you explain why this will fail on all but MySql?