简体   繁体   中英

Grouping total sales by weekly

it's I'm a newbie on SQL. so I want to make a query that makes a trend of sales by weekly. but when I tried to using this query, somehow the result does not start from Monday to Sunday. How do I solve this problem?

Thanks

select count(sales), week(paymentdate) as weekly
from sales
group by weekly

Check week() and you will find need to set mode for it

   select count(sales), week(paymentdate,1) as weekly
    from sales
    group by weekly

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