[thelist] Weird SELECT DISTINCT error
Luther, Ron
Ron.Luther at hp.com
Fri Dec 16 07:43:57 CST 2005
Matt Warden noted:
>>... it is difficult to see how DISTINCT could operate on only one
column.
Hi Matt,
?Que?
DISTINCT, (as I understand it anyway), operates across all of the fields
in your select statement.
Soooooo ... running a simple 'select distinct' on a single column turns
out to be a nice neat trick to get a quick list of all of the unique
values in that column.
Want to know all of the countries you have shipped product to so far
this
month? A simple 'Select Distinct Ship_To_Country From Some_Ship_Table
Where Ship_Date >= 1-Dec-2005', (formatted for your db du jour), should
get you that list of countries.
Very handy stuff. [With a smallish db I've seen folks use 'select
distinct's to populate their drop-down controls.]
HTH,
RonL.
More information about the thelist
mailing list