标签:group ble where bsp style col 字段 rom pre
这个题目比较坑,没有描述清楚
create TABLE #TB ( ID INT, 科目 int, 成绩 int ) select * from #TB insert into #TB(ID,科目,成绩) select 1,66,66 union select 1,55,55 union select 1,55,65 union select 2,66,66 union select 2,55,55 union select 3,66,66 --ID唯一,这个最简单 SELECT ID FROM #TB WHERE 科目>60 and 成绩>60 --ID不唯一,成绩和科目不唯一 SELECT ID FROM #TB WHERE ID not in (select ID from #TB where 科目<=60 and 成绩<=60 ) group by ID --比较LOW select ID FROM #TB group by ID having min(科目)>60 and min(成绩)>60 --最简洁
一张表三个字段ID科目成绩,查出所有科目成绩都60以上的ID
标签:group ble where bsp style col 字段 rom pre
原文地址:https://www.cnblogs.com/Bokeyan/p/14043526.html