简体   繁体   中英

SQL code to find the total sum of sales amount by each person by day

enter image description here

Hi, I have a data table shown in the image above. I want a result whereby the code finds each person's total (sum) sales amount by day. eg, for Salesperson Frank, it returns his sales for Monday, Tuesday, Wednesday, etc.

Thanks

SELECT SalesPerson, Week, Day, SUM(SalesAmount)
FROM myTABLE
GROUP BY SalesPerson, Week, Day
ORDER BY SalesPerson, Week

Use a day number field if you want to order by week day.

If you don't want to group by week, suppress Week field from previous query.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM