获取年工作日
SELECT DATEPART ( YY, jobdate ) 年, DATEPART ( mm, jobdate ) 月, count( * ) 工作日 FROM jobrecord_workday where DATEPART ( YY, jobdate )='2022' GROUP BY DATEPART ( YY, jobdate ), DATEPART ( mm, jobdate )
sql根据id去重
with infos as ( SELECT ROW_NUMBER() OVER ( PARTITION BY Infoid order by id desc) rowNum , * FROM [InfoTops] t1 with(nolock) ) select * from infos where rowNum=1 ---------------》
Infoid 是按照Infoid 去重 按照id排序
min group by 也可以去重 分组取最小的值