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.
Author |
Topic |
Blessed1978
Yak Posting Veteran
97 Posts |
Posted - 2014-03-12 : 22:20:04
|
I have a query that Is creating duplicate values exampleselectsd.vp, sd.rep,sd.create_dt ed.address, ep.salesfrom table1 sdinner join table2 edon sd.id = ed.idinner join table 3 epon ed.id = ep.idwhere vp = 'Mark Smith'group by sd.vp, sd.rep, ed.address, ep.salesthe problem with this query is that for each vp it should ONLY have a DISTINCT rep with their total sales for the dAY however this querry is producing the vp with the same rep and same sale amount duplicating 3 times.MARK SMITH candy brown 123 somwher st 21000MARK SMITH candy brown 123 somwher st 21000MARK SMITH candy brown 123 somwher st 21000 a distinct would be good but can I place the distinct by the sd.rep? so that it returns the rep only onceMARK SMITH candy brown 123 somwher st 21000 |
|
VeeranjaneyuluAnnapureddy
Posting Yak Master
169 Posts |
Posted - 2014-03-13 : 01:08:12
|
select Distinctsd.vp, sd.rep,sd.create_dt ed.address, ep.salesfrom table1 sdinner join table2 edon sd.id = ed.idinner join table 3 epon ed.id = ep.idVeera |
|
|
|
|
|