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 |
kyssling
Starting Member
1 Post |
Posted - 2014-04-17 : 15:16:38
|
Hi please I need help with following problem :tableone : contract 100001tabletwo :payments, reimbursement10000101,10010000102,20010000103,500now i need sum for every contract LEFT(payments,6) ... i use next(i use next left joins on other tables without problem in this SELECT) :LEFT OUTER JOIN(SELECT payments, LEFT(LTRIM(STR(Payments)), 6) AS PayContract, SUM(reimbursement) AS ContractSumFROM dbo.tabletwoGROUP BY Payments) Uhrady ON LEFT(LTRIM(STR(Uhrady.Payment)), 6) = LTRIM(STR(tableone.Contract)Output:for every payments ... thats bad i need some asLEFT OUTER JOIN(SELECT payments, LEFT(LTRIM(STR(Payments)), 6) AS PayContract, SUM(reimbursement) AS ContractSumFROM dbo.tabletwoGROUP BY LEFT(LTRIM(STR(Uhrady.Payment)), 6)) Uhrady ON LEFT(LTRIM(STR(Uhrady.Payment)), 6) = LTRIM(STR(tableone.Contract)but this is error Payment invalid ....Anybody can me help please ? |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2014-04-17 : 16:04:01
|
>>Anybody can me help please ?Maybe but I can't tell what the question is.If you are getting an error then post the entire actual statement you are running and the exact error message text. If you want to provide tables with sample data that is great but you need to post executable DDL/DML. ie: working CREATE TABLE statements and actual INSERT VALUES statements with your sample data. Finally the expected results based on your sample data.Be One with the OptimizerTG |
|
|
|
|
|
|
|