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 |
dave_kwok
Starting Member
1 Post |
Posted - 2012-08-07 : 04:01:49
|
hi there,Let said i have 2 tableE.g. TableA- Transactionno- POno- Invno- AmountTableB- Transactionno- POno- text- AmountData is like thisTable ATransaction no | PONo | Invno | Amount 12345 | 54321| 33333 | 100Table BTransaction no | PONo | Text | Amount12345 | 54321 |BANK123 | -10012345 | 54321 |Supplier | 100How can i get a return like below (Return only 1 row where the Amount in Table B = -100Transaction no | PONo | Invno | Text | Amount12345 | 54321| 33333 | BANK123 | 100 |
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2012-08-07 : 04:47:58
|
SELECT a.TransactionNO, a.PONo, a.Invno, b.Text, a.AmountFROM TableA a INNER JOIN TableB bWHERE a.TransactionNO = b.TransactionNOAND b.Amount = -100--------------------------http://connectsql.blogspot.com/ |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-07 : 09:59:12
|
your sample output is contradicting with rule suggested. the explanation shows you need row with Amount=-100 and output shows the one with 100.Will amount be always 100/-100? whats if there are multiple ones with amount as 100?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|