SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 denormalize table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

damegu
Starting Member

Czech Republic
5 Posts

Posted - 08/27/2014 :  05:25:49  Show Profile  Reply with Quote
Hello,
I would like to know if it is possible to do a SELECT statement where I can denormalize my table. I am not sure if it is needed to create a new table at first and insert denormalized values into the created table.


example
original table:
ID XXX VALUES
1 a 10
1 b 15
1 c 8

And I want to use SELECT to get this table:
ID a b c
1 10 15 8

khtan
In (Som, Ni, Yak)

Singapore
17681 Posts

Posted - 08/27/2014 :  06:12:13  Show Profile  Reply with Quote

SELECT *
FROM   (
           SELECT ID, XXX, VALUES
           FROM   original_table
       ) d
       PIVOT
       (
             MAX(VALUES)
             FOR XXX IN ([a], [b], [c])
       ) p



KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.34 seconds. Powered By: Snitz Forums 2000