How do I limit my SQL output to one record per student?

5 pts.
Tags:
SQL
SQL Query
SQL Records
Current resuls: Student ID: Guardian 2 Joe 2 Mary 3 Goldie 4 JIm Needed results: Student ID: Guardian 2 Joe 3 Goldie 4 Jim

Answer Wiki

Thanks. We'll let you know when a new response is added.

You could use a query like this:

select student_ID,min(Guardian)
from YourTAble
group by student_ID;

if u want first student id from same multiple st id then u can go
select * from table name where rowid in (select min(rowid) from table name group by student_id)

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Denny Cherry
    Sounds like you have an error in your data, and you need to change the Student Id for Mary.
    66,195 pointsBadges:
    report
  • carlosdl
    I thought of it also, but at the end, I assumed that Joe and Mary are the 'guardians' of an student with student_id = 2. Richieg, could you please help us with this ?
    69,940 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following