Score
0
Watch 44 Star 256 Fork 69

xuthus / 数据库SQL实战SQLMIT

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
14.从titles表获取按照title进行分组2.md 541 Bytes
Copy Edit Web IDE Raw Blame History
xuthus authored 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

题解

Comment ( 0 )

Sign in for post a comment