sql递归,按照日期显示每天
--实例
declare @dt1 date
declare @dt2 date
set @dt1 = '2016-05-30'
set @dt2 = '2016-06-13 23:59:59';
WITH dates
as(
select @dt1 as dt
union all
select dateadd(day, 1, T1.dt) as dt from dates T1
where 1=1
and T1.dt < @dt2
)
SELECT * from dates
--================================
with cte as
(
select Id,Pid,DeptName,0 as lvl from Department
where Id = 2
union all
select d.Id,d.Pid,d.DeptName,lvl+1 from cte c inner join Department d
on c.Id = d.Pid
)
select * from cte
当你的才华还撑不起你的野心时,那你就应该静下心来学习;当你的能力还驾驭不了你的目标时,那就应该沉下心来历练!