By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,254 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,254 IT Pros & Developers. It's quick & easy.

how to get distinct values from one column only

P: 62
I am using access 2010 and trying to write query where i am selecting 5 fields from table and i want distinct values but for first column only
Expand|Select|Wrap|Line Numbers
  1. select field1,field2,field3,field4,field5 from tablename;
  2.  
As i said i want distinct value in first column only,i added distinct after select but it works for all fields not for only first column
Jan 6 '14 #1
Share this Question
Share on Google+
6 Replies


zmbd
Expert Mod 5K+
P: 5,397
You may not be using the correct SQL tool for what you want.
Please provide a sample of your data (if confidential then somehting the resembles the data as closly as possible). Then explain which records you want returned.
Jan 6 '14 #2

Rabbit
Expert Mod 10K+
P: 12,366
How is it supposed to know which row you want if there are two rows with the same field1 yet the other fields are different?
Jan 6 '14 #3

zmbd
Expert Mod 5K+
P: 5,397
Exactly Rabbit, hence my request for the dataset and more detail on the desired records returned.
Jan 6 '14 #4

NeoPa
Expert Mod 15k+
P: 31,494
Rahul. See Rabbit's post #3, which explains why what you ask for is impossible. Not because it is technically complicated, but simply because it cannot make logical sense.
Jan 7 '14 #5

P: 62
ya i agree but i found way to do it i simply used group by in query and fields which are different i selected where and gave criteria in it
thanks for your replys
Jan 10 '14 #6

NeoPa
Expert Mod 15k+
P: 31,494
Let us be absolutely clear about this, as many others read this than simply those of us contributing to the thread, and your last comment could be very confusing for some.

You did not find a way to do it, as specified earlier in your question. You may well have found a way to get what you needed. I am not suggesting you are being false with us at all. I merely point out that what you actually asked for is not possible, and there is no way to do that.
Jan 10 '14 #7

Post your reply

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