--查找单据总量
select COUNT(1) as ‘表XXXXXX数据量‘ from XXXXXXwith(nolock)
--按季度查找单据总量
select count(1) as ‘表XXXXXX每季度数据数量‘,B.YQ as ‘XXXXXX季度‘ FROM
(
select A.TN_NO,cast(DatePart(Year,A.CREATED_DATE) AS varchar(10))+‘0‘+cast(DatePart(Quarter,A.CREATED_DATE) AS varchar(10)) AS YQ ---拼接年季度字符串
from (
select TN_NO,CREATED_DATE from XXXXXXwith(nolock)---查找底层数据源
)A
)B GROUP BY B.YQ order by B.YQ desc
原文:https://www.cnblogs.com/catherine9192/p/9073177.html