Pinback Posted June 15, 2018 Share Posted June 15, 2018 (edited) Hi, I want to summarise my monthly sales results per day (see Attachment). That's my current code: SELECT sum FROM tb WHERE year=selected_year AND month=selected_month ORDER BY day ASC But instead of showing each single sale I want to summarise all sales per day and show the total sum. How can I do this? THX Simon Edited June 15, 2018 by Pinback Link to comment Share on other sites More sharing options...
justsomeguy Posted June 15, 2018 Share Posted June 15, 2018 "Sum" should be a reserved word, so hopefully something like this works: SELECT SUM(sum) FROM ... If you use the SUM function it will return a single value with that column added up. Link to comment Share on other sites More sharing options...
Pinback Posted June 18, 2018 Author Share Posted June 18, 2018 Thx , you're right. But in this case this isn't the prob... As I described I need the sum of each single day of all days per month. I guess I need something like DISTINCT, JOIN and SUM..but I don't know how 😞 Link to comment Share on other sites More sharing options...
justsomeguy Posted June 18, 2018 Share Posted June 18, 2018 You probably just need to use GROUP BY with SUM. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now