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 |
|
tig2810
Starting Member
9 Posts |
Posted - 2010-02-26 : 19:35:37
|
| HiI need to join 2 tables but the key i'm using to join the tables is duplicated 3 times in one of the tables so I get a row inflation problem. I was therefore thinking i need to join to a subquery but i just cant work it out and was hoping for some assistance. SELECT Department, AccountCode, InvoiceNumber, InvoiceDate, Amount, JournalFROM LedgerWHERE AccountCode LIKE 'RC%' AND (AllocationMkr <> 'P') ORDER BY Amount-- but I also want to show the credit limit and payment terms-- chart of accounts - below filters entries so that only 1 record ---- per account is returned(SELECT DISTINCT AccountCode, CreditLimit, PaymentTermsFROM ChartOfAccountsWHERE (DB_Code = 'CBX') and AccountCode like 'RC%')Could someone help my get this to work please?thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-26 : 23:28:20
|
| [code]SELECT l.Department, l.AccountCode, l.InvoiceNumber, l.InvoiceDate, l.Amount, l.JournalFROM Ledger lJOIN (SELECT DISTINCT AccountCode, CreditLimit, PaymentTermsFROM ChartOfAccountsWHERE (DB_Code = 'CBX') and AccountCode like 'RC%') cON c.AccountCode = l.AccountCodeWHERE l.AccountCode LIKE 'RC%' AND (l.AllocationMkr <> 'P') ORDER BY l.Amount[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
tig2810
Starting Member
9 Posts |
Posted - 2010-02-27 : 09:24:34
|
| Excellent! Thanks very much. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-27 : 10:44:30
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|