|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help - selecting all rows that contain one distinct column
Hello,
I need a query that will return rows that are distinct by one Column(CD.Title). I am using two tables User and CD. The results look something like this when I perform a select joining the two. CD.ID| CD.userID | CD.Title | CD.Description| User.Name| 1 40 xxxx zzzz Jason 2 40 yyyy aaaa Jason 3 40 xxxx nnnn Jason 4 40 xxxx xxxxx Jason The Query looks like this SELECT CD.cdID, CD.UserID, CD.Title, CD.Description, User.Name FROM User, CD WHERE CD.UserID = User.userID AND CD.UserID = 40 How do I get my query to return only CD.ID| CD.userID | CD.Title | CD.Description| User.Name| 2 40 yyyy aaaa Jason 4 40 xxxx xxxxx Jason I only want it to return rows that contain the last CD.Title that is unique. Im using MSSQL. Any help is greatly appreciated. Thank you, Jason |
|
#2
|
|||
|
|||
|
Try adding a where clause for cd.id. Something like:
where cd.id = MAX(cd.id) That should select the last entry for you. I hope this helps. |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Help - selecting all rows that contain one distinct column |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|