Page 1 of 1

Selecting DISTINCT Records

Posted: Mon Nov 22, 2010 9:05 am
by amplifire
Hello everyone!

I Want to ask that how can i do this.

1) This is my table (StudentInfo) in database
Name Age Ph. No. Address
Abc 12 0000 Street1
Pqr 13 4444 Street2
Xyz 12 6666 Street3
Pqr 13 4444 Street2
Pqr 13 4444 Street2

2) I want to pick up DISTINCT records based on Age Field. However i can use
"SELECT DISTINCT Age FROM StudentInfo"

But this way i can only fetch the Age Field. How can I fetch the rest of the fields namely Name, Ph. No., Address.

Suggestions Appreciated
Regards

Re: Selecting DISTINCT Records

Posted: Mon Nov 22, 2010 9:08 am
by Celauran

Code: Select all

SELECT *, DISTINCT(Age) FROM Studentinfo

Re: Selecting DISTINCT Records

Posted: Mon Nov 22, 2010 9:10 am
by amplifire
Thanx Celauran!!

I found it, should go like this
SELECT DISTINCT Age,Name,Address FROM StudentInfo.