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)
 select

Author  Topic 

DENIZ3E
Yak Posting Veteran

56 Posts

Posted - 2005-12-02 : 17:16:01
HI,
I have got a table.
table
----------------------------
linenr stockref linetype total sale rate NAME
------- -------------- -------------- ----------- --------- ---------
0 0 SALE 100 1,4 A
0 0 SALE 200 2 B
1 34 normal 400 0
2 0 SALE 100 1,6 C
3 0 SALE 150 5,6 D
4 0 SALE 200 7 E
5 45 normal 500 0
6 0 SALE 150 10 C
8 0 SALE 100 11,5 D
9 0 SALE 150 10 E

This table is an example of an INVOICE.

I WANT TO returns

Stockref TOTAL A B C D E
------------ --------- ---------- -------- ------- ------------ ----------
34 400 400*1.4 400*2 400*1.6 400*5.6 400*7
45 500 500*1.4 500*2 500*10 500*11.5 500*10


400= price of stock number 34




nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2005-12-02 : 21:43:57
You need to explain your business logic more clearly. How are we supposed to know which rate to apply to the totals? For example, how does one know that the rate of 7 is supposed to be used for "E" for stock #34 and a different rate of 10 is used for stock #45?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-03 : 02:06:39
Seems Cross tab
http://weblogs.sqlteam.com/jeffs/archive/2005/05.aspx

Madhivanan

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

- Advertisement -