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)
 Crosst Tab Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-05-13 : 08:11:56
Franceene writes "I am working w/ a table that has a column of type decimal, and the others are varchar. Using the following crosstab query w/ the varchars and they work fine... but w/ the decimal I modify it, but it's still not working.. Please see my examples below.. THANKS

QUERY:

For varchar
SELECT LATA, NPA, NXX, Range,ST,
Rank_1=MAX(substring(Company,1,datalength(Company)*(CASE Rank when 1 then 1 else 0 END))),


For Decimal
SELECT LATA, NPA, NXX, Range,ST,
Rate_1=SUM(Rate)*(CASE Rank when 1 then 1 else 0 END),

RESULT:
Ie.

LATA | NPA | NXX | Range | ST | Rate_1 |
1111 121 213 23 ME .45
1111 121 213 23 ME .00
1111 121 213 23 ME .00

I don't want there to be more than one instance of each record.. each record has up to 12 rate(s) range(s)..
Any ideas would be awesome..

THANKS"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-05-13 : 08:17:40
Cross-tabs, get yer red-hot cross-tabs here!

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

Thank god you submitted this, I was getting withdrawal symptoms from my daily cross-tab question fix.
Go to Top of Page
   

- Advertisement -