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 |
|
lovinguy
Starting Member
12 Posts |
Posted - 2009-07-03 : 12:40:41
|
| HI!I know my question is something do with inner join but i am new to SQL so I need help.Table 1 -Sales_mainColumns name (DocNo,docdate,netamount)Table 2 - Sales_detailColumns name (Docno,docdate,amount)Table 1 has total amount or sum of a transaction but details of the transaction is in Table 2.For example if customer purchased 4 items then total amount of 4 items is in only Table 1 but Table 2 has details of individual items with amount.I need a query that if netamount=5 in Table1 then I should get details of the transaction from Table2.Waiting for reply.Thanks Lovinguy |
|
|
singularity
Posting Yak Master
153 Posts |
Posted - 2009-07-03 : 13:53:06
|
| select Docno, docdate, amountfrom Sales_detailwhere Docno in (select Docno from Sales_main where netamount = 5) |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-07-04 : 02:47:10
|
| try this too SELECT Docno, docdate, amountfrom Sales_detail dwhere EXISTS (select * from Sales_main where netamount = 5 AND docno = d.docno)SELECT d.docno,d.docdate,d.amountfrom sales_Detail dinner join sales_main m on m.docno= d.docnoand m.netamount = 5 |
 |
|
|
|
|
|