Min和Max有重复 - SQL

时间:2017-05-09 07:31:31

标签: sql database

我有这张桌子

@import "foundation";
@import "settings";
@import "motion-ui";

@include foundation-everything;

@import "top-bar";
@import "front-page";
@import "article";

我想要检索具有最小和最大学分的课程名称,我感到困惑,因为有超过最小值。那么,我如何能够显示课程名称除了最大值之外还有最低学分?提前致谢 这是我的查询

courseId| courseNmae|Credits
------------------------------
100     |DB         |2
------------------------------
101     |CS         |3
------------------------------
102     |OS         |2
------------------------------
104     |AI         |4

1 个答案:

答案 0 :(得分:0)

尝试:

select courseNmae from t 
where credit in (
    select min(credit) from t 
    union 
    select max(credit) from t 
)