当前位置:网站首页>MySQL winter vacation self-study 2022 12 (1)
MySQL winter vacation self-study 2022 12 (1)
2022-07-04 00:19:00 【Crane paper thousand】
function
group_concat
Data preparation
create database mydb4;
use mydb4;
create table emp
(
emp_id int primary key auto_increment comment ' Number ',
emp_name char(20) not null default '' comment ' full name ',
salary decimal(10,2) not null default 0 comment ' Wages ',
department char(20) not null default '' comment ' department '
);
insert into emp(emp_name,salary,department)
values(' Zhang Jingjing ',5000,' Finance Department '),
(' Wang Feifei ',5800,' Finance Department '),
(' Zhao Gang ',6200,' Finance Department '),
(' Liu Xiaobei ',5700,' The personnel department '),
(' Wang Dapeng ',6700,' The personnel department '),
(' Zhang Xiaofei ',5200,' The personnel department '),
(' Liu yunyun ',7500,' The sales department '),
(' Liu Yunpeng ',7200,' The sales department '),
(' Liu Yunpeng ',7800,' The sales department ');part1
-- Put the names of all employees in one line
select group_concat(emp_name) from emp;The operation results are as follows

part2
-- Specify the separator
select group_concat(emp_name separator ';') from emp;The operation results are as follows

part 3
-- Splicing after grouping
select department,group_concat(emp_name separator ';') from emp group by department;
part 4 Sort by salary
-- Splicing after grouping , And sort
select department,group_concat(emp_name order by salary desc separator ';') from emp group by department; 
边栏推荐
- Gossip about redis source code 73
- Iclr2022: how does AI recognize "things I haven't seen"?
- Gossip about redis source code 81
- Zipper table in data warehouse (compressed storage)
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- Selenium library 4.5.0 keyword explanation (II)
- SQL data update
- A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
- D23:multiple of 3 or 5 (multiple of 3 or 5, translation + solution)
- Development and application of fcitx functional plug-ins
猜你喜欢

Investment demand and income forecast report of China's building ceramics industry, 2022-2028

2022 t elevator repair registration examination and the latest analysis of T elevator repair

Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution

Analysis: misunderstanding of choosing WMS warehouse management system

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

Alibaba cloud container service differentiation SLO hybrid technology practice

Regular expressions and text processors for shell programming

Introducing Software Testing

Idea set class header comments

(Video + graphics and text) introduction to machine learning series - Chapter 4 naive Bayes
随机推荐
2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
After the Lunar New Year and a half
【leetcode】374. Guess the size of the number
Minimum commission for stock account opening. Stock account opening is free. Is online account opening safe
Double efficiency. Six easy-to-use pychar plug-ins are recommended
Qtcharts notes (V) scatter diagram qscatterseries
How to write a good title of 10w+?
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
P1656 bombing Railway
Global and Chinese market of breast cancer imaging 2022-2028: Research Report on technology, participants, trends, market size and share
China standard gas market prospect investment and development feasibility study report 2022-2028
[about text classification trick] things you don't know
No qualifying bean of type ‘com. netflix. discovery. AbstractDiscoveryClientOptionalArgs<?>‘ available
Is user authentication really simple
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
D29:post Office (post office, translation)
Regular expressions and text processors for shell programming
The first game of the new year, many bug awards submitted
Zipper table in data warehouse (compressed storage)
Research Report on the scale prediction of China's municipal engineering industry and the prospect of the 14th five year plan 2022-2028