------------恢复内容开始------------
- sql 统计总结: https://www.cnblogs.com/snake-hand/p/3181728.html,例子: 统计所有员工的业绩
select s.Email,SUM(cast(ach.Paid as money)) from (select * from T_Staff where State=1) as s left join T_Achievement as ach on ach.SaleUser_ID=s.ID where ach.Null2='2022-1' group by all s.Email
- 递归查询,适合自循环级联查询
with cte as( select NO,Null4 from T_Contract where No='X21-87' union all select a.No,a.Null4 from T_Contract as a inner join cte as b on b.Null4=a.No ) select No from cte
------------恢复内容结束------------