while循环控制表的样式
来源:互联网 发布:暴雪伊利丹手办淘宝 编辑:程序博客网 时间:2024/05/18 02:35
select AwardID,t.TypeID,
DepartmentName,UserName,
UG_Name,T.AwardType,
T.AwardReason,convert(nvarchar(10),T.AwardTime,121) as 'AwardTime',T.Inactive
into #temp
from T_GLGZ_AwardInfo T
left join View_UserInfo v on t.userid= v.userid
where inactive = 0
declare @PrimaryIDTable table
(
AwardID int,
typeid nvarchar(10),
DepartmentName nvarchar(50),
UserName nvarchar(50),
UG_Name nvarchar(50),
AwardType nvarchar(50),
AwardReason nvarchar(100),
AwardTime nvarchar(50),
Inactive nvarchar(10)
)
--记录奖励类型
declare @typecount int
set @typecount = 0
while @typecount <=1
begin
--统计总条数
declare @count int
--记录总条数
declare @recount int
set @count = (select count(1) from T_GLGZ_AwardInfo where TypeID =@typecount)
set @recount = @count
WHILE @count >=0
BEGIN
if @recount = @count
begin
insert into @PrimaryIDTable
select top 1* from #temp where typeid = @typecount
end
else if @recount != 0 and @count = 0
begin
insert into @PrimaryIDTable
select '','合计',count(1),'','','','','','' from #temp where typeid = @typecount
end
else
begin
insert into @PrimaryIDTable
select AwardID,'',DepartmentName,UserName,UG_Name,AwardType,AwardReason,AwardTime,Inactive from #temp
where AwardID not in(select AwardID from @PrimaryIDTable) and typeid = @typecount
end
SET @count = @count - 1
END
SET @typecount = @typecount + 1
end
select AwardID,case typeid when '0' then '奖励' when '1' then '惩罚' when '合计' then '合计' end as 'TypeID',
DepartmentName,UserName,UG_Name,AwardType,AwardReason,AwardTime,Inactive
from @PrimaryIDTable
drop table #temp
- while循环控制表的样式
- while(cin)循环的控制判断
- 循环控制 while
- python while循环控制
- 循环控制 for while do while switch
- while循环控制输入(3)
- SQL循环执行while控制
- shell计算器while循环控制
- 流程控制:while/until循环
- SQL循环执行while控制
- SHELLcase流程控制和for、while循环语句的使用
- [第3天] 程序的控制结构 (循环)[while]、[do while]、[for]
- while循环的使用
- Python的while循环
- 简单的while循环
- while循环的中断
- while循环的语法
- While循环的运用
- 论软件项目的进度管理1-电力行业工作票
- SENS:系统事件通知服务 和 WMI 支持灵活而有效的移动网络计算
- 类模块
- Symbian使用freetype实现自定义字体功能
- CString类
- while循环控制表的样式
- .NET 2.0 VS .NET 1.0
- 作家鄭石岩
- C#数据结构与算法之栈浅析
- 数据压膜模式
- 论软件项目的进度管理2-综合业务信息系统的开发
- ctrl+alt+方向键 与win7的旋转屏幕冲突解决
- 大整数加减乘除运算类
- KbmMW,DevExpress 49版本,RemObjects SDK,Indy组件在Delphi7的结合方式