Home > Blockchain >  How to filter unique records in SQL based on conditons?
How to filter unique records in SQL based on conditons?

Time:11-30

I have this data, with student id, names, education, and completion year.

How I can display only one row for each alumni, such that If an alumnui has completed more than one study program, the row of the table with the last completed study level will be retained.

Please see image below for data!

enter image description here

CodePudding user response:

Question: How to filter unique records in SQL based on conditons? Answer: Condition part you can use "Where" clause and filter unique records you can use "Distinct" or "Group By" clause.

CodePudding user response:

I suggest you to use the GROUP BY feature like that :

SELECT id, name, education, MAX(year)
FROM data
GROUP BY id;
  • Related