Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query is having repeated values
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

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

Aged Yak Warrior

737 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

Premature Yak Congratulator

22864 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


Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000