Click here to Skip to main content
16,022,536 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some data. Here's.

SQL
Name     Car1    Car2    Car3
AAA      BMW     NULL    NULL
BBB      NULL    HAMMER  NULL
CCC      TOYOTA  NULL    NULL
DDD      NISSAN  HAMMER  NULL
EEE      FORD    NULL    NULL


But, I have a problem and I can't do the following.

SQL
Name     BMW  FORD  HAMMER  NISSAN  TOYOTA
AAA      1    0     0       0       0
BBB      0    0     1       0       0
CCC      0    0     0       0       1
DDD      0    0     1       1       0
EEE      0    1     0       0       0


Someone can help me. Thanks.
Posted
Comments
Mehdi Gholam 25-Sep-11 1:33am    
This is called a pivot on counts.

Have a look at PIVOTS here[^].
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900