sql - 如何计算此查询给出的结果数
问题描述
with events as (select count(distinct b."SubstituteTeacher"), row_number() over (partition by b."SubstituteTeacher" order by d."StartTime") as seq from dbo."Accounts" a
full outer join dbo."WorkContracts" b on a."ID" = b."SubstituteTeacher" .
full outer join dbo."SubstituteTeacherPeriods" c .
on a."ID" = c."SubstituteTeacher" .
full outer join dbo."OrderPeriods" d .
on a."ID" = d."CreatedBy"
full outer join dbo."Addresses" e .
on a."Address" = e."ID"
full outer join dbo."StandardCities" f
on e."City" = f."ID"
full outer join dbo."Orders" g
on d."Order" = g."ID"
where a."ID" != 16 and a."ID" != 11797
and b."WorkContractType" != 3
group by d."StartTime", b."SubstituteTeacher")
select * from events where seq = 1 ;
解决方案
从 seq = 1 的事件中选择 Count(*)
推荐阅读
- python - Python 3:关于在函数中使用变量的理论问题
- java - 继承中的 ClassCastException - 为什么?
- javascript - 如何使用 FormData 对象获取文件名?
- reactjs - React:将 Screen.js 更改为 LandScape 方向
- angular - ag-grid - 将字符串过滤为数值而不更改数据类型
- c++ - 如何使用 typename 的类型?
- python - 当其他列具有某些值时查找 groupby 计数
- c# - 如何重新启用 Visual Studio 自动跨步通知?
- javascript - 当我在 nextjs 的 jsx 中使用 if 时,类名会感到困惑
- android - whereArrayContains 限制为 10