Using a DISTINCT query
-
Hi there, I have tried running a query using the DISTINCT keyword, but the result is not what i am looking for. The table is something like the following:
name age
AA 12
BB 13
cc 18
AA 14
BB 19If i query:
Select Distinct name, age from table;
i get all the rows. I am intested in a result set that will be:
name age
AA 12
BB 13
cc 18Can anyone help? Thank! Edit: 1. I know that distinct works on the combination of the colunms, giving a distinct set of rows, but that is not what i need. I need it to be distincted by the name. 2. Running
Select Distinct(name), age from table;
doesn't give the correct result either.
modified on Sunday, October 11, 2009 10:37 AM
-
Hi there, I have tried running a query using the DISTINCT keyword, but the result is not what i am looking for. The table is something like the following:
name age
AA 12
BB 13
cc 18
AA 14
BB 19If i query:
Select Distinct name, age from table;
i get all the rows. I am intested in a result set that will be:
name age
AA 12
BB 13
cc 18Can anyone help? Thank! Edit: 1. I know that distinct works on the combination of the colunms, giving a distinct set of rows, but that is not what i need. I need it to be distincted by the name. 2. Running
Select Distinct(name), age from table;
doesn't give the correct result either.
modified on Sunday, October 11, 2009 10:37 AM
Just to let you know, i solved the problem.
select distinct(name), age from table group by name;
did the job. Thanks.
-
Just to let you know, i solved the problem.
select distinct(name), age from table group by name;
did the job. Thanks.