我有这个简单的SQL查询,我试图为uni项目运行。我收到了标题中的错误但是我运行了一个非常相似的查询,没有问题。
select booking.customer_id, booking_start_date
SUM(total_cost) sales
from booking
order by 2 desc
提前致谢。
答案 0 :(得分:5)
,
之后您错过了booking_start_date
。
尝试 -
select booking.customer_id,
booking_start_date,
SUM(total_cost) sales
from booking
GROUP BY booking.customer_id, booking_start_date
order by 2 desc
答案 1 :(得分:0)
尝试以下方法..
select
booking.customer_id
, booking.start_date
, SUM(booking.total_cost) sales
from
booking
group by
booking.customer_id
, booking.start_date
order by
2 desc
答案 2 :(得分:0)
这是您更新的查询。当您使用COUNT,SUM,MIN,MAX等聚合函数时,也应该使用GROUP BY。
select booking.customer_id, booking_start_date
SUM(total_cost) sales
from booking group by booking.customer_id, booking_start_date
order by 2 desc