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
53.按照dept_no进行汇总.md 503 Bytes
Copy Edit Web IDE Raw Blame History
xuthus authored 2019-08-12 23:23 . add:all

按照dept_no进行汇总

题目描述

按照dept_no进行汇总,属于同一个部门的emp_no按照逗号进行连接,结果给出dept_no以及连接出的结果employees

CREATE TABLE `dept_emp` (
`emp_no` int(11) NOT NULL,
`dept_no` char(4) NOT NULL,
`from_date` date NOT NULL,
`to_date` date NOT NULL,
PRIMARY KEY (`emp_no`,`dept_no`));

答案

select dept_no,group_concat(emp_no) from dept_emp group by dept_no

题解

聚合函数group_concat的使用

Comment ( 0 )

Sign in for post a comment