August 21, 2008 at 4:10 am
I have table like this
ID Style Cap
468 Theatre 350
468 Classroom 160
468 Boardroom 50
468 Banqueting 230
468 Cabaret 150
468 Dinner 230
468 Drinks 400
my required output:
ID Theatre Classroom Boardroom Banqueting Cabaret Dinner Drinks
468 350 160 50 230 150 230 400
please help
August 21, 2008 at 4:32 am
What you need (since you are on SQL Server 2005) is pivots with dynamic SQL. I've put some examples on:
http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx
Regards,
Andras
August 21, 2008 at 4:47 am
He only has to read the replies here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=109222
N 56°04'39.16"
E 12°55'05.25"
August 21, 2008 at 4:53 am
Peso (8/21/2008)
He only has to read the replies here
Well spotted :), the answer there (at the time of this post) addresses the problem if the pivot values are static. If they are not, you will still need to use dynamic SQL.
Regards,
Andras
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply