SQL256. 出现三次以上相同积分的情况
描述
在牛客刷题的小伙伴们都有着牛客积分,积分(grade)表简化可以如下:
id | number |
1 2 3 4 5 | 111 333 111 111 333 |
id为用户主键id,number代表积分情况,让你写一个sql查询,积分表里面出现三次以及三次以上的积分,查询结果如下:
111 |
示例1
输入:
drop table if exists grade; CREATE TABLE `grade` ( `id` int(4) NOT NULL, `number` int(4) NOT NULL, PRIMARY KEY (`id`)); INSERT INTO grade VALUES (1,111), (2,333), (3,111), (4,111), (5,333);
输出:
111
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3364KB, 提交时间: 2021-09-12
SELECT number FROM grade GROUP BY number HAVING COUNT(number) >=3;
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3368KB, 提交时间: 2021-09-13
select number from grade group by number having count(number)>=3
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3368KB, 提交时间: 2021-09-09
select number from grade group by number having count(number)>=3;
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3368KB, 提交时间: 2021-09-08
select number from grade group by number having count(number)>=3
Sqlite 解法, 执行用时: 10ms, 内存消耗: 3368KB, 提交时间: 2021-09-07
select number from grade group by number having count(number)>=3