Problem: not every month has recruit and leave, not simple subtraction, also could be a month without hiring also does not have the number of departure, this month's value should be zero
Whether to need to use a stored procedure, how to write? There are more simple method?
SQL:
Select count (distinct a.f personid) the number of new TLEVEL2, entry_year, entry_month
The from RECRUITMENT a
Where TLEVEL2='pharmaceutical division and entry_year=2017
Group by entry_year entry_month, TLEVEL2
The order by entry_year, entry_month
;
Recruitment
-- -- -- -- --
Select
Count (distinct a.f personID) the number of departure, level2 stores, a. EAVEDATE_YEAR, a. EAVEDATE_MONTH
The from DIMISSION a
Where level2 stores='pharmaceutical division and LEAVEDATE_YEAR=2017
Group by level2 stores, a. EAVEDATE_YEAR, a. EAVEDATE_MONTH
The order by LEAVEDATE_MONTH
-- -- -- -- --
leaving
CodePudding user response:
Feel it is ok to get a viewCodePudding user response:
If the number of departure that month than hiring? Net how to calculate?CodePudding user response: