|
最佳回答 |
1
|
axingLv6专家互助发布于2020-3-24 15:02
|
select 年级,
AVG(case when convert(varchar(10),日期,23) between '${dateinweek(today(),1)}' and '${today()}' then 实际得分 else 0 end) 本周年级平均分,
AVG(case when convert(varchar(10),日期,23) between '${dateinweek(today()-7,1)}' and '${dateinweek(today()-7,-1)}' then 实际得分 else 0 end) 上周年级平均分
from dbo.班级日考核
where convert(varchar(10),日期,23) between '${dateinweek(today()-7,1)}' and '${today()}'
GROUP BY 年级
|
|
|
|
最佳回答 |
1
|
qq1320929786Lv6初级互助发布于2020-3-24 15:01
|
with a as( select 年级,'年级平均分' = AVG(实际得分) from dbo.班级日考核 where convert(varchar(10),日期,23) between '${dateinweek(today(),1)}' and '${today()}' GROUP BY 年级 ), b as ( select 年级,'年级平均分' = AVG(实际得分) from dbo.班级日考核 where convert(varchar(10),日期,23) between '${dateinweek(today()-7,1)}' and '${dateinweek(today()-7,-1)}' GROUP BY 年级 )
select * from a left join b on a.年级=b.年级
|
|
|
|
最佳回答 |
1
|
明明1117Lv6见习互助发布于2020-3-24 15:01
|
|
|
|
|
最佳回答 |
1
|
小歆嵩Lv7初级互助发布于2020-3-24 15:02
|
select 年级,'本周年级平均分' = AVG(实际得分)
from dbo.班级日考核
where convert(varchar(10),日期,23) between '${dateinweek(today(),1)}' and '${today()}'
GROUP BY 年级
union all
select 年级,'上周年级平均分' = AVG(实际得分)
from dbo.班级日考核
where convert(varchar(10),日期,23) between '${dateinweek(today()-7,1)}' and '${dateinweek(today()-7,-1)}'
GROUP BY 年级
|
|
|
|
最佳回答 |
0
|
shirokoLv6资深互助发布于2020-3-24 15:00
|
|
|
|