423,109 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,109 IT Pros & Developers. It's quick & easy.

Using DISTINCT in a WHERE Clause

100+
P: 416
To save some code I would like to put a distinct clause in the criteria for a report. I've created a table that I'm using for multiple reports but in some of the reports I only need one instance of a record but need multiples of that record in other reports. I'm using the same report layout with 7 different criteria's. So is there a way to put a distinct clause or some other statement that would select only unique records in a where clause(criteria)
I hope this makes some sense
Jan 6 '18 #1

✓ answered by NeoPa

DISTINCT is a keyword used in the SELECT clause only. It cannot be used in the WHERE clause as that would make absolutely no sense. You could use a GROUP BY clause and have similar results but it wouldn't be exactly the same thing.

Are you thinking about using a filter string?

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 30,909
DISTINCT is a keyword used in the SELECT clause only. It cannot be used in the WHERE clause as that would make absolutely no sense. You could use a GROUP BY clause and have similar results but it wouldn't be exactly the same thing.

Are you thinking about using a filter string?
Jan 7 '18 #2

100+
P: 416
No I'm not thinking of a filter. I'm thinking that I will create a couple of queries one with the distinct. I'll create them in the program in the section before I print the reports.
Jan 7 '18 #3

NeoPa
Expert Mod 15k+
P: 30,909
In that case you should now have all the information you need.

Be aware there are two related keywords :
DISTINCT
DISTINCTROW

The first applies only to the fields SELECTed whereas the second applies to the whole row regardless of which fields are used.
Jan 7 '18 #4

Post your reply

Sign in to post your reply or Sign up for a free account.