Reputation: 64
I have MYsql table data in following manner.
user-id |salecount |datetime
2 40 2014-04-11 23:53:58
2 30 2014-04-11 23:32:14
2 30 2014-04-12 23:32:14
4 56 2014-04-11 22:32:14
4 70 2014-04-12 20:32:14
4 10 2014-04-12 20:32:14
I want output like date wise user total.
For above input i want output.
user-id |saletotal |date
2 70 2014-04-11
2 30 2014-04-12
4 56 2014-04-11
4 80 2014-04-12
Please help me for this.
Upvotes: 2
Views: 34
Reputation: 29051
Try this:
SELECT a.user_id, SUM(a.salecount), DATE(a.datetime)
FROM tableA a
GROUP BY a.user_id, DATE(a.datetime);
Upvotes: 2
Reputation: 6132
try this:
SELECT user_id,SUM(salecount),DATE(DATETIME) FROM tablename1
GROUP BY user_id, DATE(DATETIME)
Upvotes: 0