Pivot without aggregate

872 views Asked by At

Please help me with this. I have the data as this:

ID          Name          TotalCost     
----   ----------------  ----------  
1      Wash, Dry & Fold     175.00    
2      Hand Wash and Fold   275.00
3      Pressing Only        25.00   
4     Hand Wash and Fold    205.00
5     Dry Clean             395.00
6     Pressing Only         100.00

I would like to display my table like this: Is this possible using PIVOT without Agrregate?

ID     Wash, Dry & Fold    Hand Wash and Fold  Pressing Only    Dry Clean 
----   ----------------   -----------------    --------------   -----------
1         175.00    
2                              275.00
3                                                                25.00   
4                              205.00
5                                                               395.00
6                                                 100.00

Thank you.

1

There are 1 answers

3
Webdev On BEST ANSWER
select *
from 
(
  select ID, Name, TotalCost
  from Table
) src
pivot
(
  sum(TotalCost)
  for Name in ('Wash, Dry & Fold','Hand Wash and Fold','Pressing Only','Dry Clean' )
) piv;