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 |
|
fischer_andreas
Starting Member
1 Post |
Posted - 2011-10-20 : 16:09:21
|
| Hello Team,I have a SQL Script:use db_xySELECT KOSTKKA.KKa_Nr AS KA, KOSTKKA.KKa_Bez AS KABEZ, right(KOSTKKS.KKs_Nr,4) AS KST, KOSTKKS.KKs_Bez AS KSTBEZ, MONTH(KOSTKBU.KBu_BelDat) AS Monat, YEAR(KOSTKBU.KBu_BelDat) AS Jahr, KOSTKBU.KBu_BelDat AS BelDat, KOSTKBU.KBu_Text AS BuchTXT, (case When KOSTKBU.KBU_Haben = -1 then KOSTKBU.KBU_Euro * (-1) Else KOSTKBU.KBU_Euro END ) AS BetragFROM KOSTKBU INNER JOIN KOSTKKS ON KOSTKBU.KKs_IdSoll = KOSTKKS.KKs_Id INNER JOIN KOSTKKA ON KOSTKBU.KKa_IdSoll = KOSTKKA.KKa_IdWHERE (KOSTKKS.KKk_id=11)order by KAThe same script is with "where ...kkk_id=12)"--> So. With id=11 and id=12.These are financial datas with two cost-circles (is this the right expression.....?)Every account record is with date/money/text/cost1/cost2Cost1 is kkk_id=11 and Cost2 is kkk_id=12every statement works fine within itself. But I want a integrated statement:e.G.:Kost-Art Kostenstelle Betrag4000 100 500whithin:4000 101 2004000 102 2004000 103 100sum is 500.....The first part is from ...kkk_id =11The second part is from ...kkk_id = 12sort criteria is "KA", in this case 4000. How can I make this?It should be a Group By oder so? I can not program it.Thank youAndreas |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2011-10-20 : 18:34:49
|
| WHERE (KOSTKKS.KKk_id in (11, 12) ???=======================================Faced with the choice between changing one's mind and proving that there is no need to do so, almost everyone gets busy on the proof. -John Kenneth Galbraith |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-21 : 00:41:22
|
| you want costs in different columns or consolidated into same column?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|