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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Condition with Inner Join

Author  Topic 

pradeepbliss
Starting Member

28 Posts

Posted - 2015-03-20 : 05:41:35
I have Two tables @master and @child

Master Table :
MasterID EntryNumber BranchId IsstockIn
1 1 1 1

2 1 1 0

Child Table:
CEntryNumber CBranchID EntryQty
1 1 10
1 1 20
1 1 -5
1 1 -4

My Query:
Select SEC.EntryQty from Item.StockEntryChild SEC
where SEC.CEntryNo =
(
select SEM.EntryNumber from item.StockEntryMaster SEM
where SEC.CBranchID=SEM.BranchID and SEC.CEntryNo=SEM.EntryNumber and SEM.MasterID=1 and SEM.isStockIn=1
)

My Result:
EntryQty
10
20
-5
-4

Expected Result:
10
20

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2015-03-20 : 06:17:28
Try this


Select SEC.EntryQty from Item.StockEntryChild SEC inner join item.StockEntryMaster SEM
on SEC.CEntryNo = SEM.EntryNumber and
SEC.CBranchID=SEM.BranchID and SEC.CEntryNo=SEM.EntryNumber
where SEM.MasterID=1 and SEM.isStockIn=1


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

pradeepbliss
Starting Member

28 Posts

Posted - 2015-03-20 : 06:23:41
No i am getting same as actual result failed to obtain the expected result


quote:
Originally posted by madhivanan

Try this


Select SEC.EntryQty from Item.StockEntryChild SEC inner join item.StockEntryMaster SEM
on SEC.CEntryNo = SEM.EntryNumber and
SEC.CBranchID=SEM.BranchID and SEC.CEntryNo=SEM.EntryNumber
where SEM.MasterID=1 and SEM.isStockIn=1


Madhivanan

Failing to plan is Planning to fail

Go to Top of Page
   

- Advertisement -