mysql - SQL GROUP BY CLAUSE -
i have table i'm trying pull trend analysis columns date(timestamp),riskcategory(text) , point(int). i'm trying return every date sum points , group riskcategory. can latest via following:
select date,riskcategory,sum(point) total risktrend date(date) >= (select max(date(date)) risktrend) group riskcategory;
but struggling returning same dates. using mysql.
i should further elaborate, date can have multiple entries, riskcategory can administrative,availability, or capacity. so, every date should see sum of points latter three. example,
2010-10-06 capacity 508 2010-10-06 administrative 113 2010-10-06 availability 243 2010-10-07 capacity 493 2010-10-07 administrative 257 2010-10-07 availability 324
you need add date group clause:
select date, riskcategory, sum(point) total risktrend date(date) >= (select max(date(date)) risktrend) group date, riskcategory;
Comments
Post a Comment