|
--1\statistics of all employees in 2016, each month, overtime every year. The requirement is to output the total employee gh of each month's jbgs greater than 36, and the monthly output.
select gh, convert (char (7), rq, 111) YF, SUM (zbs) zbs, sum (jbgs) jbgs
--into GZB_MONTH
FROM GZMXB WHERE YEAR (rq) = '2016'
group by gh, convert (char (7), rq, 111)
having sum (jbgs)> 36
--2\outputs the gh output of employees whose total jbgs exceeded (36 * 12) 432 in 2016.
select gh, YEAR (rq) NF, SUM (zbs) zbs, sum (jbgs) jbgs
--into GZB_YEAR
FROM GZMXB WHERE YEAR (rq) = '2016'
group by gh, YEAR (rq)
having sum (jbgs)> 432
--3\compares the result of 2 with zgs.jbs in another table (gzb). The GH of different employees and the month of the current month are output.
SELECT A.gh, B.gh, A.YF, B.YF, A.zbs, B.zbs, A.jbgs, B.jbgs
FROM GZB_MONTH A FULL JOIN gzb B ON A.gh = B.gh and A.YF = B.YF
WHERE A.zbs <> B.zbs OR A.jbgs <> B.jbgs |
|