SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Ouery Issue - Using Not in
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Arunavalli
Starting Member

India
3 Posts

Posted - 07/31/2014 :  05:20:47  Show Profile  Reply with Quote
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

India
643 Posts

Posted - 07/31/2014 :  06:08:53  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
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

India
3 Posts

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

ahmeds08
Aged Yak Warrior

India
643 Posts

Posted - 07/31/2014 :  06:31:37  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
ok then add the remaining columns to the query

Javeed Ahmed
Go to Top of Page

Arunavalli
Starting Member

India
3 Posts

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

ahmeds08
Aged Yak Warrior

India
643 Posts

Posted - 07/31/2014 :  06:53:49  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
welcome

Javeed Ahmed
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000