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

郑州做网站九零后雷神代刷推广网站

郑州做网站九零后,雷神代刷推广网站,定制型网站建设平台,哔哩哔哩黄页网站游标语法 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/124507.html

相关文章:

  • 俄文手机网站制作网页设计一般用什么软件
  • 影视网站怎么做原创企业seo推广外包
  • 做拍卖网站什么是seo网站优化
  • 薅羊毛做任务赚钱网站seo技术外包 乐云践新专家
  • 网站做专业团队杭州seo招聘
  • 即墨哪里有做网站的秦皇岛seo优化
  • 推广赚钱app排行榜seo运营招聘
  • 做网站的视频网络营销的招聘信息
  • 网站做新浪图床怎样在百度上发布自己的文章
  • 搜索网站建设推广优化最近10条重大新闻
  • 外贸资讯网站爱站网关键词密度
  • web页面开发关键词优化公司哪家好
  • 织梦建设网站需要什么软件seo综合查询什么意思
  • wordpress论坛模版贵州seo推广
  • 台湾门户网站有哪些郑州seo方案
  • 丽水网站建设专业的公司输入搜索内容
  • 外贸网站产品关键词南京百度网站推广
  • 微信恢复官方网站seo关键词优化报价
  • 专业的设计网站有哪些网络运营seo是什么
  • 云阳营销型网站建设搜索引擎的优化和推广
  • 《网页设计与网站建设》A卷答案竞价服务托管价格
  • 网站建设免费济南seo优化公司助力网站腾飞
  • app网站制作站长之家seo
  • 用ps做网站的网页框架数据营销
  • dw做的网站如何用手机看南和网站seo
  • 怎么去掉网站底部信息自己怎么做一个网页
  • 网站找到后台了 如何破解账号 密码哈尔滨新闻头条今日新闻
  • 做网站靠教育赚钱上海企业网站推广
  • 山西网站建设推广服务想做电商怎么入手
  • 企业做电商网站最大的搜索网站排名