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

Pivot Sales by Quarter

Turn the rows into columns: for each product return its total amount in Q1 and Q2 as separate columns named Q1 and Q2. Order by product.

Table schema

Sales(product VARCHAR(50), quarter VARCHAR(2), amount INT)

Sample data

product | quarter | amount
Pen | Q1 | 100
Pen | Q2 | 150
Book | Q1 | 200
Book | Q2 | 50

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.