Joyиal Ali
Joyиal Ali

Reputation: 89

Pivot SQL specific Column

Im stuck with the following

I want to use the values from the hours column as actual colums

Any idea how to do this?

Name|Team|Area|Count|Hour
Bob |J1  |UK  |1    | 8
Jim |J1  |UK  |1    | 9
Tim |J1  |UK  |1    | 9
Tom |J1  |UK  |1    | 10

Upvotes: 0

Views: 39

Answers (1)

Bibin Mathew
Bibin Mathew

Reputation: 465

Change this query based on your expected rows.

 SELECT * 
 FROM 
 ( SELECT Name,Team,Area,Count,Hour FROM Tb_Name
 )
 PIVOT
     (COUNT(Name) FOR Hour IN ([8],[9],[10])) P

Upvotes: 1

Related Questions