Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Sales With Subtotals and Grand Total

Return sales per (region, product), a subtotal per region (product shown as 'ALL') and a grand total (region and product 'ALL'). Sort regions alphabetically with the grand total last, and within a region products alphabetically with the subtotal last.

Table schema

Sales(region VARCHAR(10), product VARCHAR(10), amount INT)

Sample data

region | product | amount
North | Pen | 10
North | Pen | 20
North | Book | 30
South | Pen | 5
South | Book | 15

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.