ROW_NUMBER()over(order by name) as num --- 按照某字段排序并且输出显示排序数字
select name from sysobjects where xtype='u' -- 获取数所有表名字
select name from syscolumns where id = object_id('HIS_OperationList') -- 获取指定表格的列名
(select stuff((select '字符'+[表字段] from 表名 where 条件 for xml path('')),1,1,'') -- 结果返回符号隔开的字符串
STUFF((SELECT ','+[表字段] FROM 表名 WHERE 条件 ORDER BY MCBARCODECOMPLETEC.LOT FOR XML PATH('')),1,1,'')
GROUP BY -- 分组去重
SUM(T.QualifiedRate) over( partition by T.AreaName order by T.AreaName DESC) as QualifiedRate -- 分组求和、分组计算SNO
where datediff(week,ordTime,getdate()-1)=0 -- 查询和当前时间差的数据