当前位置: 首页 > wzjs >正文

专做运动装的网站网络营销机构官方网站

专做运动装的网站,网络营销机构官方网站,设计响应式网站多少钱,怎么在word里做网站游标语法 declare c1 cursor for select title from titles --定义一个游标c1,确定游标对应的列是titles表的title列,游标可以对应多个列 declare bname varchar(50) --声明变量 open c1 --初始化,开始使用游标 fetch next from c1 in…

游标语法

declare c1 cursor for 
select title from titles

--定义一个游标c1,确定游标对应的列是titles表的title列,游标可以对应多个列

declare @bname varchar(50)

--声明变量

open c1

--初始化,开始使用游标
fetch next from c1
into @bname

--初始化游标c1到i=0,即起始位置,把游标对应列的值放入变量中,用作输出

while @@FETCH_STATUS=0

--判断游标状态,是否到最后一行
begin
 print 'the name of the book is '+@bname

--对每行做数据做相应操作
fetch next from c1
into @bname

--完成操作后,游标后移,再次把游标对应行的该列值放入变量,重复直到游标到最后一列
end

close c1 --关闭游标
deallocate c1 --销毁游标

practice

first:多个变量,聚合函数输出,返回多个字符串


declare b cursor for
select title_id from titleauthor
declare @titleid1 varchar(50),@sum1 int,@sum2 int,@sum3 int
open b
fetch next from b
into @titleid1
while @@FETCH_STATUS=0
begin
set @sum1=(select count(*) from sales where title_id=@titleid1 and ord_date between '1992-1-1' and '1992-12-30')
set @sum2=(select count(*) from sales where title_id=@titleid1 and ord_date between '1993-1-1' and '1993-12-30')
set @sum3=(select count(*) from sales where title_id=@titleid1 and ord_date between '1994-1-1' and '1994-12-30')
 print @titleid1+' '+cast(@sum1 as varchar(10))+' '+cast(@sum2 as varchar(10))+' '+cast(@sum3 as varchar(10))
fetch next from b
into @titleid1 
end
close b
deallocate b

second:多个变量,返回表


declare c cursor for
select title_id from titleauthor
declare @titleid2 varchar(50),@asum1 int,@asum2 int,@asum3 int
create table #temptable(
titleid varchar(100),
count92 int,
count93 int,
count94 int)
open c
fetch next from c
into @titleid2
while @@FETCH_STATUS=0
begin
set @asum1=(select count(*) from sales where title_id=@titleid2 and ord_date between '1992-1-1' and '1992-12-30')
set @asum2=(select count(*) from sales where title_id=@titleid2 and ord_date between '1993-1-1' and '1993-12-30')
set @asum3=(select count(*) from sales where title_id=@titleid2 and ord_date between '1994-1-1' and '1994-12-30')
insert into #temptable values(@titleid2,@asum1,@asum2,@asum3)
fetch next from c into @titleid2
end
close c
deallocate c

select * from #temptable
drop table #temptable

http://www.dtcms.com/wzjs/112929.html

相关文章:

  • 网站开发前期准备店铺推广方式有哪些
  • 完整网站模板下载seo免费培训视频
  • 自己开网站做职称论文可以吗上海关键词排名提升
  • 哪里有做彩票网站了如何seo搜索引擎优化
  • 哈 做网站重庆seo按天收费
  • 电脑上制作网页的软件网站推广seo招聘
  • 网络营销方式有哪些类型杭州网站优化搜索
  • wordpress 导出功能汕头seo公司
  • 镜像站wordpress美区下载的app怎么更新
  • 标签系统做的好的网站杭州网站推广找哪家
  • 电脑版网站建设合同范本南宁网站建设服务公司
  • 包装设计招聘长沙seo网站优化公司
  • 网站建设骗子网站排名优化
  • 湛江市住房建设局网站疫情最新消息今天
  • 网站项目策划书方案免费网站seo排名优化
  • 匠王红木在那个网站做众筹青岛网站排名推广
  • 网站seo诊断工具seo网站排名优化公司
  • vue 做电商网站中国最好的营销策划公司
  • 做网站企业贵阳网站建设
  • 网站建设的原则有哪些qq群怎么优化排名靠前
  • 网站空间ip查询人民政府网站
  • 赣州网站建设中心杭州seo渠道排名
  • 网站建设栏目添加百度知道灰色词代发收录
  • 网站备案怎么查好f123网站
  • 有个网站经常换域名百度关键词检测工具
  • 广州响应网站建设站长平台网站
  • 百度做销售网站多少钱网推软件有哪些
  • 网站在线支付接口申请搜索引擎优化推广
  • 公司做网站的费用如何记账比较好的品牌策划公司有哪些
  • 什么系统做购物网站好友情链接平台站长资源