Im trying to sum() the quantity field on my select query grouping them by the date value but Sql keep giving me errors saying not al columns are grouped in my GroupBy but i only wantt o group them by Date
This is my query:
SELECT Date, Clave_PDV, Che, Lin, Dish, Dish_Name, Type,
sum(Quantity) as Quant, Price, Total, Tur, Tur_Name, Group,
Group_Name, Pdv_Name, St_Pla, St_Che
FROM Dish_Sales
GROUP BY Date
How can i Sum(Quantity) grouping them by Date?
You would remove all the columns you do not want:
SELECT Date, sum(Quantity) as Quant
FROM Dish_Sales
GROUP BY Date;
If you want the sum by date you should us e
SELECT Date, sum(Quantity) as Quant
FROM Dish_Sales
GROUP BY Date
Otherwise you should use the group by for all column not aggregated
SELECT Date, Clave_PDV, Che, Lin, Dish, Dish_Name, Type,
sum(Quantity) as Quant, Price, Total, Tur, Tur_Name, Group,
Group_Name, Pdv_Name, St_Pla, St_Che
FROM Dish_Sales
GROUP BY Date, Clave_PDV, Che, Lin, Dish, Dish_Name, Type,
Price, Total, Tur, Tur_Name, Group,
Group_Name, Pdv_Name, St_Pla, St_Che
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.