gpt4 book ai didi

php - MySQL SUM 与分组日期

转载 作者:行者123 更新时间:2023-11-29 11:15:50 26 4
gpt4 key购买 nike

如何获取带有分组日期的数据价格?

SELECT store.date, store.pic, owner.name, 
SUM (CASE WHEN [>>GROUPED store.date<<] THEN store.price) AS total_price
FROM store
JOIN owner
ON store.pic = owner.name GROUP BY store.date

我想像这样显示:

+-------------+------+------------+
| date | name | price |
+-------------+------+------------+
| 2016-09-30 | John | 100000.00 |
| 2016-09-29 | Rey | 125000.00 |
+-------------+------+------------+

最佳答案

试试这个可能会对你有帮助,

 SELECT store.date, store.pic, owner.name,SUM(store.price) AS total_price
FROM store
JOIN OWNER ON store.pic = owner.name
GROUP BY store.date

我不明白为什么你在查询中使用 case 语句

关于php - MySQL SUM 与分组日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39786362/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com