|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
My SQL statemnet is as follows
SELECT dbo.Client.ClientID, dbo.Client.ClientName, dbo.Contact.ContactName, dbo.Client.Notes FROM dbo.Client Inner Join dbo.Contact ON dbo.Client.ContactID = dbo.Contact.ContactID Well I want to add on a statement so that it selects all these but I want dbo.Contact.ContactName to be distinct. I am not sure how to do this, Gerbill
__________________
Open source to the open minded... |
|
#2
|
||||
|
||||
|
you can't group a query with only one of the items in the select clause.
SELECT dbo.Client.ClientID, dbo.Client.ClientName, dbo.Contact.ContactName, dbo.Client.Notes FROM dbo.Client Inner Join dbo.Contact ON dbo.Client.ContactID = dbo.Contact.ContactID group by dbo.Client.ClientID, dbo.Client.ClientName, dbo.Contact.ContactName, dbo.Client.Notes it depends on what the table looks like, if you have more more than 1 note per clientname then you'll see duplicate clientnames. if you 1note to 1client to 1contactname etc, you can just use the grouping above. hope that helps. |
|
#3
|
||||
|
||||
|
Yeah it is great thanks. I was trying to do another impossible SQL statement.
I was just trying to kill two problems with one SQL statement. Thanks again, Gerbill |
|
#4
|
||||
|
||||
|
Glad to help.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Selecting Distinct values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|