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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT DISTINCT not working 1

Status
Not open for further replies.

BrenoAguiar

IS-IT--Management
Feb 8, 2005
81
0
0
US
HI folks,

I have this query that I want it to bring ONLY DISTINCT folio numbers and the SQL viw is like this:

SELECT DISTINCT guesttrack_clean.Folio, brochure.type
FROM brochure INNER JOIN guesttrack_clean ON brochure.homephone = guesttrack_clean.HomePhone
WHERE ((([BookingDate]-[datesubmit])>0))
ORDER BY brochure.lastname;

But this is still giving me duplicate values in the guesttrack_clean.folio .

Any help?
Thanks a lot
 
Obviously you have more than one record for each one...it seems to me that you may have 2 different values in both records. I.e., brochure.type could equal "this" in one record and "that" in another.
 
Yes. But Can I Use the DISTINCTROW instead, in order to eliminate the ROW, based ONLY on the guesttrack_clean field with no duplicates. In other words, disregarding the brochure.type beeing "this" or "that" ?
 
I believe what threadgills is suggesting is to just remove brochure.type.
 
I did that. But I have a report that is attached to the query and I need that info to show on the report, but not as a sort item. I created a another query, reading off this one WITHOUT brochure.type, just the guesttrack_clean.Folio (which brings the right number of records withou dups) but if I add another field on the SELECT, here comes the duplicates again, even reading out off the query that has only the records with no dups.

 
If you had the following duplicate:
Folio, Type
1, 1
1, 2

What result are you looking for?
1, 1
1, 2
or just 1

You can use Min() and Max() to capture a single Folio, and then use Min(Type) or Max(Type) to take only one of the Type results.
 
I meant to say...
You can use Min() and Max() to capture a single Folio, by using Min(Type) or Max(Type) to take only one of the Type results.
 
Good. Thanks for that. what I needed was the result "just 1" that you mentioned and I'm using Max().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top