[已恢复] SQL查询不同的输出 [英] [Resoved] SQL query different output
本文介绍了[已恢复] SQL查询不同的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试这个sql查询
选择 tblRV.ID as ID,tblRV.Owner,tblRV.Regno,
(选择计数(*) 总来自 tblvv WHERE MID = tblRV.ID 和名称<> ' ')
as total,tblRV.MA,tblRV.MS from tblReg inner join tblRV On tblReg.RID = tblRV.RID
WHERE tblReg.StartDate> = ' 2016-06-01 00:00:00' AND
tblReg.EndDate< = ' 2016-06-08 23:59:59'
和 tblReg.Region = ' UK'
< span class =code-keyword> order by tblRV.Owner
此查询返回24行,所以当我创建程序然后我执行这样的存储过程
我尝试过:
grid_data ' UK',' 2016-06-01 00:00:00',< span class =code-string>' 2016-06-08 23:59:59'
sp
ALTER procedure [dbo]。[grid_data]
@ region varchar ( 50 ),
@ fromdate datetime ,
@ todate datetime
as
选择 tblRV.ID as ID,tblRV.Owner,tblRV.Regno,
(选择计数(*) as 总来自 tblvv WHERE MID = tblRV.ID 和名称<> ' ')
as total,tblRV.MA,tblRV.MS from tblReg inner join tblRV On tblReg.RID = tblRV.RID
订单 tblRV.Owner
这显示我24913条记录。
解决方案
在Sp中你没有使用where where where WHERE tblReg.StartDate> = @fromdate AND
tblReg.EndDate< = @todate
和tblReg.Region = @ region
把它放在Sp中你会得到你想要的结果。
I try this sql query
Select tblRV.ID as ID, tblRV.Owner, tblRV.Regno,
(Select Count(*) as total from tblvv WHERE MID = tblRV.ID and Name <> '')
as total,tblRV.MA, tblRV.MS from tblReg inner join tblRV On tblReg.RID = tblRV.RID
WHERE tblReg.StartDate >= '2016-06-01 00:00:00' AND
tblReg.EndDate <= '2016-06-08 23:59:59'
and tblReg.Region = 'UK'
order by tblRV.Owner
this query return me 24 rows so when i create procedure then i exe store procedure like this
What I have tried:
grid_data 'UK' ,'2016-06-01 00:00:00', '2016-06-08 23:59:59'
sp
ALTER procedure [dbo].[grid_data]
@region varchar(50),
@fromdate datetime,
@todate datetime
as
Select tblRV.ID as ID, tblRV.Owner, tblRV.Regno,
(Select Count(*) as total from tblvv WHERE MID = tblRV.ID and Name <> '')
as total,tblRV.MA, tblRV.MS from tblReg inner join tblRV On tblReg.RID = tblRV.RID
order by tblRV.Owner
THIS SHOW ME 24913 records.
解决方案
In Sp you did not use where condition WHERE tblReg.StartDate >= @fromdate AND
tblReg.EndDate <= @todate
and tblReg.Region =@region
Put it in Sp you will get your desired result.
这篇关于[已恢复] SQL查询不同的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文