Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DISTINCT List
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01091597
Message ID:
01091638
Views:
16
The DISTINCT clause applies to all columns in the list (the whole record).

>What's the syntax for multiple columns with DISTINCT?
>
>BOL only shows a single column.
>
>
>
>>Try
SELECT DISTINCT ...
>>
>>
>>>The following query works - to a point.
>>>
>>>It returns ALL the invoice records. All invoice records for a station are marked
>>>with the same invoice #, user and Done Date.
>>>
>>>I need a list that is distinct on those 3 columns, so that I only get 1 invoice record
>>>for each combination of invoice #, user and done date.
>>>
>>>Thanks
>>>
>>>
>>>select ri.id,
>>>       st.station_name,
>>>       ri.invoice_no,
>>>       ri.user_name,
>>>       ri.done_date_time
>>>  from document doc
>>>  join media_order mo on mo.document = doc.id
>>>  join media_order_detail mod on mod.media_order = mo.id
>>>  join recon_info ri on ri.mod_dtid = mod.id
>>>  join station st on st.id = doc.station
>>>  where st.station_name= 'KTLA'
>>>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform