Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Transpose

Author  Topic 

ramkirangj
Starting Member

7 Posts

Posted - 2008-11-18 : 02:11:43
I have a table which contains n number of elements and values for them. Some times the value may be 0.

I want only the elements whose value is not 0 as columns

Can any one help me out

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-18 : 05:44:36
http://weblogs.sqlteam.com/jeffs/archive/2005/05/02/4842.aspx
Go to Top of Page

ramkirangj
Starting Member

7 Posts

Posted - 2008-11-18 : 08:14:28
Thank u very much for the link.

I have tried that one but the problem is that procedure is working only for one element in the pivot column. But, I have n number of elements in pivot column.

if my table is as follow

sno Dept no.of employee payelement value
1 HR 30 basic 8888
2 HR 30 HRA 2222
3 Tech 10 basic 5555
4 Tech 10 HRA 2222



Then i want the output as

Sno Dept No.of Employees Basic HRA
1 HR 30 8888 2222
2 Tech 10 5555 2222



In stead i am getting the output as


Sno Dept No.of Employees HRA
1 HR 30 2222
2 Tech 10 2222

That means it is taking only the last element
Here i gave only two elements but in real i have total elements of 130 which keep changing from month to month

Please help me out

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 08:54:11
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx
Go to Top of Page

ramkirangj
Starting Member

7 Posts

Posted - 2008-11-21 : 05:21:18
Thank you very much for the reply I got the answer
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-21 : 06:24:06
welcome
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-21 : 07:26:08
quote:
Originally posted by ramkirangj

Thank you very much for the reply I got the answer


For the first time I have seen this requirement in this forum and happy that my solution worked

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-21 : 08:57:27
quote:
Originally posted by madhivanan

quote:
Originally posted by ramkirangj

Thank you very much for the reply I got the answer


For the first time I have seen this requirement in this forum and happy that my solution worked

Madhivanan

Failing to plan is Planning to fail


Owe me a treat for this
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-21 : 09:38:19
quote:
Originally posted by visakh16

quote:
Originally posted by madhivanan

quote:
Originally posted by ramkirangj

Thank you very much for the reply I got the answer


For the first time I have seen this requirement in this forum and happy that my solution worked

Madhivanan

Failing to plan is Planning to fail


Owe me a treat for this




Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -