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
 Selecet DISTINCT plus more

Author  Topic 

flyadvertising
Starting Member

2 Posts

Posted - 2011-02-06 : 01:14:39
The following is working great, but I need to get one more row from the second table (ppics). However, when I try to add this in, my query stops working. Any help will be much appreciated.

SELECT ppre.cID, ppre.yr, ppre.make, ppre.model, ppre.vin, ppre.display FROM ppre
JOIN (SELECT DISTINCT pcID FROM ppics) AS TR
ON TR.pcID = ppre.cID

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-02-06 : 07:25:58
You need one more ROW from the 2nd table?

are you saying you need more DISTINCT pcID's ?

What do you mean "Stops working"?



Poor planning on your part does not constitute an emergency on my part.
Go to Top of Page

flyadvertising
Starting Member

2 Posts

Posted - 2011-02-06 : 21:06:45
Sorry, I meant 1 more COLUMN, ppics.purl. This should not pull all of the distinct values in ppics.purl, rather just the ppics.purl that is associated with the ppics.pcID.

By "stops working", I mean when I try to pull in this column, I lose the filtering of the distinct pcID and I see the entire database displayed.
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2011-02-07 : 08:47:30
What are you expecting? How can you have distinct IDs if each ID can have multiple purl ? What you are asking for makes no sense:
pcID purl
1 abc
2 def
2 ghi
3 jkl

what would you expect to see differently if you select DISTINCT rows?
Go to Top of Page
   

- Advertisement -