--查询指定供应商指定的一段时间内出票的张数
declare @date1 date
declare @date2 date
declare @startdate date
declare @enddate date
declare @countsum int
declare @count int
set @startdate='2010-06-01'
set @enddate='2011-07-01'
set @count=1
set @countsum=DATEDIFF(MM,@startdate,@enddate)
set @date1=@startdate
set @date2=dateadd(mm,1,@startdate)
while @count<@countsum
begin
--执行sql
SELECT SUM(PassengerCount) AS 张数 FROM dbo.Orders WHERE ProviderID =
(SELECT UserId FROM dbo.User
WHERE Username='wind2006')
and OrderTime Between @date1 and @date2
set @date1=dateadd(mm,@date1) set @date2=dateadd(mm,@date2) set @count=@count+1 end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。