当前位置: 数据库>sqlserver
sql分类汇总及Select的自增长脚本
来源: 互联网 发布时间:2014-10-08
本文导语: 如图: 其中Num是自增长列,Operation是分类标签,count是汇总数据 脚本如下: 代码如下: select Num=row_number() OVER(order BY HT_Resv.OperationStatus),HT_Resv.OperationStatus , CASE HT_Resv.OperationStatus WHEN '3' THEN '成功' WHEN '4' THEN '失败' end as 'Status',count(...
如图:
select Num=row_number() OVER(order BY HT_Resv.OperationStatus),HT_Resv.OperationStatus ,
CASE HT_Resv.OperationStatus
WHEN '3' THEN '成功'
WHEN '4' THEN '失败'
end as 'Status',count(HT_Resv.Id) as 'Count'
FROM ht_resv group BY HT_Resv.OperationStatus
其中Num是自增长列,Operation是分类标签,count是汇总数据
脚本如下:
代码如下:
select Num=row_number() OVER(order BY HT_Resv.OperationStatus),HT_Resv.OperationStatus ,
CASE HT_Resv.OperationStatus
WHEN '3' THEN '成功'
WHEN '4' THEN '失败'
end as 'Status',count(HT_Resv.Id) as 'Count'
FROM ht_resv group BY HT_Resv.OperationStatus