Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL:我想计算我的员工成本,并按员工和天数分组_Mysql_Date_Group By_Sum - Fatal编程技术网

MySQL:我想计算我的员工成本,并按员工和天数分组

MySQL:我想计算我的员工成本,并按员工和天数分组,mysql,date,group-by,sum,Mysql,Date,Group By,Sum,我目前有一个表格,记录所有员工的日常开支 John Smith 01 JAN 2010 200$ John Smith 01 JAN 2010 50$ John Smith 01 JAN 2010 10$ Lady Gaga 01 JAN 2010 50$ Lady Gaga 01 JAN 2010 20$ John Smith 02 JAN 2010 10$ 我希望显示一个包含所有账单的每日报告的表格: 01 J

我目前有一个表格,记录所有员工的日常开支

John Smith    01 JAN 2010    200$ 
John Smith    01 JAN 2010    50$
John Smith    01 JAN 2010    10$
Lady Gaga     01 JAN 2010    50$ 
Lady Gaga     01 JAN 2010    20$
John Smith    02 JAN 2010    10$
我希望显示一个包含所有账单的每日报告的表格:

01 JAN 2010
John Smith: 260$
Lady Gaga: 70$

02 JAN 2010
John Smith: 10$
我真的希望我的要求是可以理解的,你将能够帮助我


非常感谢你的建议

我将通过以下方式使用标准组:

select date, name, sum(amount) as total
from mytable
group by 1,2
order by 1,2;
与GROUP BY一起使用,执行以下操作

SELECT date,user,SUM(cost)
FROM mytable
GROUP BY  date,user
ORDER BY  date