x

Displaying mutiple rows as mutiple in columns.

Hi ,

I have one problem, displaying data in columns.

I have EX: emptable

empid    Sal

1         10
2         20
3         30
4         40
5         50
.
.
.
.

100
.
.
Etc

i want this change in multiple differnt columms, in select query or in store procedure any way

Ex: Empid as header and sal as columun

                    
1   2   3   4   5  ..... 100 etc                    
10  20  30  40  50 .......... etc.                    

Please help in how slove this problem

Thanks Raja

more ▼

asked Nov 12, 2009 at 08:25 AM in Default

avatar image

venkatesh
1 1 1 1

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

You need a Cross-tab or Pivot

For example see: http://weblogs.sqlteam.com/jeffs/archive/2005/05/02/4842.aspx

more ▼

answered Nov 12, 2009 at 08:38 AM

avatar image

Kristen ♦
2.2k 7 11 14

(comments are locked)
10|1200 characters needed characters left
more ▼

answered Nov 12, 2009 at 09:25 AM

avatar image

Madhivanan
1.1k 2 5 9

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2018
x103

asked: Nov 12, 2009 at 08:25 AM

Seen: 1108 times

Last Updated: Nov 12, 2009 at 08:36 AM

Copyright 2016 Redgate Software. Privacy Policy