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.
| Author |
Topic |
|
BusteR
Starting Member
17 Posts |
Posted - 2004-04-15 : 03:53:26
|
| HiSubject is not well said but... it's not easy to describe my prob. with one sentence.Table structure:key x y z 1 1 1 23 2 1 2 453 1 7 324 1 3 155 2 3 676 2 9 45etc.X would be something like a document number, Y would be a brand and Z will be a quanity. I have to create a few groups of brands [1<>3, 4<>6, 7<>9 ...] and i have to sum quanities for each group and get it in 1 row for each document. It should look like that:x G1 G2 G31 83 0 322 67 0 45etc.I hope i made myself clear [sorry for my poor english and lack of imagination in this one]... it is very important to me and i have no idea how to get those 3 columns out of one :/I would be gratefull for any help.Best Regards |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
|
|
BusteR
Starting Member
17 Posts |
Posted - 2004-04-15 : 04:09:07
|
| Thank you very very much!:) |
 |
|
|
BusteR
Starting Member
17 Posts |
Posted - 2004-04-16 : 03:57:54
|
| Hi again...unfortunately database has changed and now...i have to get a price of things that are in db. Price is in database but in diffrent table then quanity... everything would be perfect, but... in groups there are diffrent prices..so i've trided to do it like this:Sum(CASE when ob_TowId IN (5, 6, 7, 8, 9, 10, 11, 12, 13) AND ob_TowId = koszt_TwId Then ob_Ilosc * koszt_Cena else 0 end)whereob_TwoId, koszt_TwId = Id of product in 2 tablesob_Ilosc = quanitykoszt_Cena = pricebut it gets me wrong results, is there any way to do it in one query or do i have to create a sum for every product?It would be nothing but.. when i do it in one SUM() then it is easier for me to do it dynamic in php.Best regards. |
 |
|
|
|
|
|
|
|