October 27, 2024
Chicago 12, Melborne City, USA
SQL

How to pivot data in sql


I am trying to structure this sample data in SQL and I’m not sure how to go about doing this.

enter image description here

I want my Sql table to be structured as
enter image description here

I tried the below but again I’m not sure how to even create a pivot in SQL Server.

Select *
From Estimates
PIVOT (
SUM (turnover)
For segment in ( pulp,san)
)



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video