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 |
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2008-02-21 : 13:57:30
|
| Ok I have two tablesclients and expensesenpense table columns: clientid, expensetype, expensevalueclients.clientid and expenses.clientid relate the tow tables on an inner joinwhat i have is one client that will have multiple expense records in the expense tablecleint1, expensetype1, expensevalue1cleint1, expensetype2, expensevalue2cleint1, expensetype3, expensevalue3what i need to output is client.*, sum(expensevalues), and also expensevalue1, expensevalue2, expensevalue3 as one output linehow do I get this? |
|
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2008-02-21 : 15:07:53
|
| i got it -- what a major headachefor anyone elsemain query with a left join and a case statementsomething likesum(case when new_categoryname = 'Title Insurance' then new_amount end) as [Title Insurance], |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2008-02-21 : 15:53:12
|
| You might want to add an "ELSE 0" to your case statement or you might get NULL values for [Title Insurance]... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-22 : 01:42:18
|
| For more information, read about Cross-tab Reports in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|