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)
 How to Solve This...

Author  Topic 

anjan
Starting Member

21 Posts

Posted - 2005-11-04 : 08:52:30
When I am executing the crosstab query
(which is given in this forum -crosstab query with four parameters)

it's working fine for single sum statement.

but..i want to execute the query in the following format.
How can i get that??? waiting for ur response...

exec Crosstab
'Select temp2 from temp group temp2',
'convert(varchar,sum(temp11))+convert(varchar,sum(temp11))',
'temp1',--pivot
'temp'--table

Here i'm concatinating the two 'sum' fields.

X002548
Not Just a Number

15586 Posts

Posted - 2005-11-04 : 10:14:41
Some sample data and desired results would be nice.

Read the hint link in my sig



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

anjan
Starting Member

21 Posts

Posted - 2005-11-05 : 07:24:40
my Temp table data is:

temp1 temp2 temp5 temp11
10 A 5 150.00
20 B 1 100.00
10 A 2 50.00

required output is :

temp2 10 20
-------------------------------
A [7]200.00 null
B null [1]100.00
Go to Top of Page

anjan
Starting Member

21 Posts

Posted - 2005-11-05 : 07:31:28
why i'm not getting the above result with this query


exec Crosstab
'Select temp2 from temp group temp2',
'['+'convert(varchar,sum(temp5))'+']'+ convert(varchar,sum(temp11))',
'temp1',--pivot
'temp'--table
Go to Top of Page
   

- Advertisement -