1

Topic: SQL request about a partition on days

Hello, there are two tables status (id, name) and persons (id, name, (foreign key status) id_status, (reception date) date_employ,
(Dismissal date) date_uneploy). Prompt please how it is possible to make request which would deduce an amount of employees of the selected status accepted or dismissed on operation for the given time frame with a partition on days? Especially interests, how it is possible to make in this case a partition on days?

2

Re: SQL request about a partition on days

declare @d1 date = ' 20170801 ', @d2 date = ' 20170901 ';
with u as (select Soctojanie = N' ', id_status, [date] = cast (date_uneploy as date), [an amount of employees] = count (*) from persons where date_uneploy between @d1 and @d2 group by id_status, cast (date_uneploy as date))
, e as (select Soctojanie = N' ', id_status, [date] = cast (date_employ as date), [an amount of employees] = count (*) from persons where date_employ between @d1 and @d2 group by id_status, cast (date_employ as date))
, ue as (select * from u union all select * from e)
select ue.c
, The status = s.name
, ue. [date]
, ue. [An amount of employees]
from ue left outer join status as s on s.id = ue.id_status
;

3

Re: SQL request about a partition on days

aleks222;
Thanks respected ! I will understand.