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
 Transact-SQL (2000)
 Query

Author  Topic 

dewacorp.alliances

452 Posts

Posted - 2003-01-18 : 18:33:46
Hi there

I had 3 tables which the structure like this:

tblAsset:
+ AssetID int
+ Name varchar(50)

tblSplitSet:
+ SplitSetID
+ AssetID

tblSplit:
+ SplitID
+ SplitSetID
+ Percentage

The sample data for each table are:
tblAsset:
+ 1; Mobile Phone
+ 2; PC

tblSplitSet
+ 10; 1
+ 11; 2

tblSplit:
+ 100; 10; 50;
+ 101; 10; 50;
+ 102; 11; 25;
+ 103; 11; 25;
+ 104; 11; 50;

If I join these 3 tables it will be like:
+ 1; Mobile Phone; 100; 10; 50;
+ 1; Mobile Phone; 101; 10; 50;
+ 2; PC; 102; 11; 25;
+ 2; PC; 103; 11; 25;
+ 2; PC; 104; 11; 50;

Rather than have view like that, I want to have a view/table like these:
1; Mobile Phone; 50; 50; 0; 0; 0
2; PC ; 25; 25; 50; 0; 0

Note that the maximum split is specified which is 5.

So any ideas to make a view/temp table like this

Please help

Thanks






ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-01-18 : 23:07:09
Sounds like you need a cross tab

http://www.sqlteam.com/item.asp?ItemID=2955

Go to Top of Page
   

- Advertisement -