SELECT
sum(if(trim(A.indiv) = '정상출근' or trim(A.indiv) = '지각', 1, 0)) as 'in',
sum(if(trim(A.indiv) = '지각', 1, 0)) as 'late',
sum(if(trim(A.instatus) = '휴가', 1, 0)) as 'holiday1',
sum(if(trim(A.instatus) = '오전반차', 0.5, 0)) as 'holiday2',
sum(if(trim(A.instatus) = '오후반차', 0.5, 0)) as 'holiday3',
sum(if(trim(A.instatus) = '휴일근무', 1, 0)) as 'holiday_work',
sum(if(trim(A.instatus) = '출장', 1, 0)) as 'out1',
sum(if(trim(A.overtime_status) = '승인', 1, 0)) as 'out2',
sum(if(trim(A.outwork_time) like '종일외근' and outwork_status='승인', 1, 0)) as 'out3',
sum(if(trim(A.outwork_time) like '오전외근' and outwork_status='승인', 0.5, 0)) as 'out4',
sum(if(trim(A.outwork_time) like '오후외근' and outwork_status='승인', 0.5, 0)) as 'out5'
from attendance as A join member as B
on A.id = B.id
where B.join <> '' 등의 적절한 조건
'[ 서버 & DB 관련 ] > MySQL' 카테고리의 다른 글
테이블 존재 여부 확인 (0) | 2019.09.04 |
---|---|
mysql 연결 오류 (타임존) - use a more specifc time zone value if you want to utilize time zone support (0) | 2019.08.08 |
MySQL - 일별통계, 주간통계, 월간통계 [펌] (0) | 2019.06.05 |
ORDER BY 특정 값에 우선순위 주기 (0) | 2019.06.05 |
MYSQL 특정 문자 치환해서 UPDATE (0) | 2019.05.23 |