简体   繁体   English

如何根据条件过滤 SQL 中的唯一记录?

[英]How to filter unique records in SQL based on conditons?

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在此处输入图像描述

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

Let me know if this works, thanks:)让我知道这是否有效,谢谢:)

Question: How to filter unique records in SQL based on conditons?问题:如何根据条件过滤SQL中的唯一记录? Answer: Condition part you can use "Where" clause and filter unique records you can use "Distinct" or "Group By" clause.答:条件部分可以使用“Where”子句,过滤唯一记录可以使用“Distinct”或“Group By”子句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM