Ask Your Question
2

How to sort SQL rollup by date name?

asked 2023-07-14 20:12:12 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-14 20:38:01 +0000

qstack gravatar image

To sort a SQL rollup by date name, you can use the ORDER BY clause in your SELECT statement. Here's an example:

SELECT date, name, SUM(quantity) FROM sales GROUP BY ROLLUP (date, name) ORDER BY date, name;

This query will first group the data by date and name, and then include subtotals for each combination of date and name. Finally, it will sort the results by date and name in ascending order.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-14 20:12:12 +0000

Seen: 9 times

Last updated: Jul 14 '23