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
 Ouery Issue - Using Not in

Author  Topic 

Arunavalli
Starting Member

3 Posts

Posted - 2014-07-31 : 05:20:47
I used 2 tables.

IT_PO_MASTER
IT_PO_PAYMENT

Common field is PONO and fin_year

I want to fetch record from IT_PO_MASTER, which record is not present in IT_PO_PAYMENT.

I tried below query. It takes value. But it return One record in 86 times ( that is 86 record in IT_PO_PAYMENT table)
///
Select a.PONO,a.PO_ALLOT,a.NOTENO,a.PODATE,a.POTYPE,a.MASTERPO,a.BRANCH_ITEM,a.PO_AMOUNT,a.BUYBACK,a.REMARKS,a.FIN_YEAR,a.DELETEFLAG from IT_PO_MASTER a, IT_PO_PAYMENT b WHERE a.DELETEFLAG='0'and a.fin_year=b.fin_year and a.pono not in (select po_no from it_po_Payment) order by a.pono asc


Kindly help me to solve this one.

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-07-31 : 06:08:53
if you just want the pono,then try this

select distinct pono from IT_PO_MASTER
where pono not in(select pono from IT_PO_PAYMENT)


Javeed Ahmed
Go to Top of Page

Arunavalli
Starting Member

3 Posts

Posted - 2014-07-31 : 06:12:11
No Sir. I want to all the fields. Whatever i mentioned in query.
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-07-31 : 06:31:37
ok then add the remaining columns to the query

Javeed Ahmed
Go to Top of Page

Arunavalli
Starting Member

3 Posts

Posted - 2014-07-31 : 06:46:36
Thank you sir. After using distinct keyword it is work good.
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-07-31 : 06:53:49
welcome

Javeed Ahmed
Go to Top of Page
   

- Advertisement -