Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Distinct and order by

Status
Not open for further replies.

mhenley

IS-IT--Management
Aug 25, 2000
27
0
0
US
I'm wanting to use the distinct function to parse duplicate records (in a stored procedure from ADO, but I don't think that is the issue). The problem is that it is not eliminiting the duplicate records??? The following is a sample of what I've tried to do. Some columns in the select and where clause as well as some joins have been removed, just to make it easier to read. Note that I'm pulling back columns of just about every data type in this select and also using several joins.

SELECT DISTINCT location.thursday_start_hours, merchant.merchant_desc, merchant.logo_small, savings.savings_id, savings.start_date, savings.end_date, savings.image_name, savings.short_desc, savings.long_desc, savings.regular_price, savings.sale_price, savings_type.savings_type_desc, mileage = 75

INNER JOIN location ON zip2.zip_code = location.zip
INNER JOIN merchant ON location.merchant_id = merchant.merchant_id
WHERE merchant.active_ind = 1
ORDER BY mileage, savings.savings_id


I read something on MSDN that suggested it may be the "order by" that is causing the problems? Any other ideas? What about the idea of comparing real numbers using a distinct? Would that keep the SQL server from thinking they are the same?

Thanks in advance for any help, mhenley.
 
Never mind, I figured it out...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top