I have a table like this (but with more columns):
Code Quantity
----- --------
00001 1
00002 1
00002 1
00002 2
00003 2
00003 1
And I want to get the same result that with SELECT DISTINCT Code FROM table
(00001,00002,00003) but with all of the other table columns.
UPDATED:
If I perform this: SELECT DISTINCT Code, Quantity from table
I get:
Code Quantity
----- --------
00001 1
00002 1
00002 2
00003 1
00003 2
And I would like to get:
Code Quantity
----- --------
00001 1
00002 1
00003 1
Thanks in advance!
Assuming you are using MySQL (as the question is tagged), the following will return an arbitrary value for the other columns:
select *
from t
group by code;
However, the particular values being selected come from indeterminate rows.