61 Star 427 Fork 145

xuthus / 数据库SQL实战

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
14.从titles表获取按照title进行分组2.md 541 Bytes
一键复制 编辑 原始数据 按行查看 历史
xuthus 提交于 2019-08-13 08:38 . revise:content revision

从titles表获取按照title进行分组,注意对于重复的emp_no进行忽略。

题目描述

从titles表获取按照title进行分组,每组个数大于等于2,给出title以及对应的数目t。 注意对于重复的emp_no进行忽略。

CREATE TABLE IF NOT EXISTS `titles` (
`emp_no` int(11) NOT NULL,
`title` varchar(50) NOT NULL,
`from_date` date NOT NULL,
`to_date` date DEFAULT NULL);

答案

select title,count(distinct emp_no) t from titles group by title having t >= 2

题解

SQL
1
https://gitee.com/xuthus5/Database-SQL-Actual-Combat.git
git@gitee.com:xuthus5/Database-SQL-Actual-Combat.git
xuthus5
Database-SQL-Actual-Combat
数据库SQL实战
master

搜索帮助