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
 Query is having repeated values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ramachandran.123
Starting Member

India
3 Posts

Posted - 11/29/2012 :  01:47:28  Show Profile  Reply with Quote

Dear Sir
I am having query

select distinct(cetshnumber), INVOICEITEMS.ItemQuantity 'Quantity Manufactured',INVOICEITEMS.ItemQuantity 'Quantity Cleared'
from INVOICEITEMS,invoice,cetsh where invoice.invoicenumber=invoiceitems.invoicenumber and
month(InvoiceDate)=11 and year(InvoiceDate)=2012 group by cetshnumber,INVOICEITEMS.ItemQuantity

I have given distinct but still the cetshnumber value is repeated for each record.


Thanks and Regards
N.Ram

ahmeds08
Aged Yak Warrior

India
573 Posts

Posted - 11/29/2012 :  01:54:55  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
looks like cetshnumber has multiple entries in other tables your are joining.
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 11/29/2012 :  02:46:41  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Note that distinct wont work that way. It is applied to entire column set and not on cetshnumber only. If there are m,ultiple ItemQuantity associated to each cetshnumber , the cetshnumber will get repeated. You may need to remove ItemQuantity in GROUP BY cluae and use min or max on it

Madhivanan

Failing to plan is Planning to fail
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.06 seconds. Powered By: Snitz Forums 2000