在牛客刷题的小伙伴们都有着牛客积分,积分(grade)表简化可以如下:
id为用户主键id,number代表积分情况,让你写一个sql查询,积分表里面出现三次以及三次以上的积分,查询结果如下:
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);
SELECT number FROM grade GROUP BY number HAVING COUNT(number)>=3