去年同期的数据

去年同期入职人数怎么查询呢

SQL 帆软用户bYtXFepsKs 发布于 2023-5-6 10:11
1min目标场景问卷 立即参与
回答问题
悬赏:0 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共4回答
最佳回答
0
snrtuemcLv8专家互助
发布于2023-11-24 18:20

sql入职人数同期上期

select a.*,b.同期,c.上期 from (select substr(入职日期,6,2)*1 m,入职日期,入职人数 from aTQ where substr(入职日期,1,4)='2019') a

left join (select  substr(入职日期,6,2)*1 m,入职日期,入职人数 as 同期 from aTQ where substr(入职日期,1,4)='2018' ) b on a.m=b.m

left join

(select substr(入职日期,6,2)+1 m,入职日期,入职人数 as 上期 from aTQ where substr(入职日期,1,4)='2019'

union

select (case when substr(入职日期,6,2)*1=12 then 1 end) m,入职日期,入职人数 as 上期 from aTQ where substr(入职日期,1,4)='2018'

最佳回答
0
Z4u3z1Lv6专家互助
发布于2023-5-6 10:11

SqlServer?oracle?mysql?

字段呢?

最佳回答
0
CD20160914Lv8专家互助
发布于2023-5-6 10:12(编辑于 2023-5-6 10:13)

where 1=1

and year_month='${FORMAT(YEARDELTA(TODAY(),-1),"yyyy-MM")}'

这样限制条件?返回去年5月的时间限制条件

最佳回答
0
FRenthusiastsLv3初级互助
发布于2023-5-6 10:15

count(1) over(partition by xxxx) 

  • 3关注人数
  • 288浏览人数
  • 最后回答于:2023-11-24 18:20
    请选择关闭问题的原因
    确定 取消
    返回顶部