반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- CES 2O21 참여
- web 개발
- paragraph
- tensorflow
- 데이터전문기관
- CES 2O21 참가
- web 용어
- classification
- html
- 결합전문기관
- 대이터
- pycharm
- Keras
- broscoding
- 재귀함수
- cudnn
- discrete_scatter
- java역사
- 웹 용어
- KNeighborsClassifier
- web 사진
- postorder
- C언어
- 자료구조
- 머신러닝
- bccard
- web
- inorder
- mglearn
- vscode
Archives
- Today
- Total
bro's coding
연습 본문
반응형
show databases;
use 인사급여;
show tables;
select *
from 사원;
select count(*), count(퇴사일자)
from 사원;
## 직급별 인원수
select 직급, count(*) as 인원수
from 사원
group by 직급;
## 직급별 인원 및 평균 월급
select 직급,count(*) as 인원수, avg(월급여)
from 사원
group by 직급;
## 급여 구분에 따른 평균 월급
select 급여구분, count(*), avg(월급여)
from 사원
group by 급여구분;
## 입사 년도별 평균 월급
select year(입사일자) as 입사년도, count(*) as 인원수, avg(월급여) as 평균월급
from 사원
group by year(입사일자)
order by 평균월급;
## 년도별, 직급별 몇명
select year(입사일자) as 입사년도, 직급 ,count(*) as 인원수,avg(월급여) as 평균월급
from 사원
group by year(입사일자), 직급
order by 입사년도, 직급;
## order
select *
from 사원
order by if(직급='대리','1_대리',if(직급='과장','2_과장','3_차장')) desc, 입사일자;
## 부서명 출력
select 사원.*,부서명
from 사원 inner join 부서
where 사원.부서코드=부서.부서코드
order by 부서명;
## 월별 급여지급 합계
select*
from 급여지급;
select 급여월, sum(월급여) as 합
from 급여지급
group by 급여월
order by 합
;
## 성과금 out join / null도 출럭
select 사원.사원번호, 사원.사원명, 급여지급.급여월, 급여지급.성과급
from 사원 left join 급여지급
on 사원.사원번호 = 급여지급.사원번호
order by 사원명
;
select 사원명, sum(급여지급.월급여) as 총급여
from 사원 left join 급여지급
on 사원.사원번호 = 급여지급.사원번호
group by 사원. 사원번호, 사원.사원명
order by 총급여 desc;
select 사원명, sum(급여지급.성과급) as 총성과급
from 사원 left join 급여지급
on 사원.사원번호 = 급여지급.사원번호
group by 사원. 사원번호, 사원.사원명
order by 총성과급 desc;
select 사원.사원명, 급여지급.성과급
from 사원 inner join 급여지급
on 사원.사원번호 = 급여지급. 사원버호;
select*
from 급여지급;
## 지역별 월별 총 급여 *********************************************check
select 부서.지역,급여지급.급여월, sum(월급여) 총급여
from 부서, 사원, 급여지급
where 부서.부서코드=사원.부서코드
group by 부서.지역, 급여지급.급여월
order by 총급여;
반응형
'[IT] > MySQL' 카테고리의 다른 글
MySQL.sampledata 불러오기 (0) | 2020.08.10 |
---|---|
MySQL.Workbench download (0) | 2020.08.10 |
MySQL download (0) | 2020.08.10 |
workbench.import csv file (0) | 2020.05.18 |
having (0) | 2020.03.20 |
macro (0) | 2020.03.20 |
CREATE TABLE (0) | 2020.03.19 |
type (0) | 2020.03.19 |
Comments