我有一個這樣的存儲過程在一個上下文中指定的非布爾類型的表達式:了條件,預期的,同時加入GETDATE()函數
alter procedure [dbo].[IBS_PodiumSummeryCount]
@locid integer=null
as
begin
SET NOCOUNT ON;
select sum(status_receved) as Receved, sum(status_parked) as Parked,
sum(status_requested) as Requested,sum(status_requestedinprocess) as Requestinprocess
from (select case when (status = 0) then 1 else 0 end as status_receved,
case when (status = 2) then 1 else 0 end as status_parked,
case when (status = 3) then 1 else 0 end as status_requested,
case when(status=4) then 1 else 0 end as status_requestedinprocess
from transaction_tbl where locid = @locid and status in (0,2,3,4)) a;
end
,但我想獲得最後24小時數據從我的SQL服務器..我添加getdate()-1在我的where條件。這樣改變了存儲的過程是這樣的:
alter procedure [dbo].[IBS_PodiumSummeryCount]
@locid integer=null
as
begin
SET NOCOUNT ON;
select sum(status_receved) as Receved, sum(status_parked) as Parked,
sum(status_requested) as Requested,sum(status_requestedinprocess) as Requestinprocess
from (select case when (status = 0) then 1 else 0 end as status_receved,
case when (status = 2) then 1 else 0 end as status_parked,
case when (status = 3) then 1 else 0 end as status_requested,
case when(status=4) then 1 else 0 end as status_requestedinprocess
from transaction_tbl where locid = @locid and getdate()-1 and status in (0,2,3,4)) a;
端 但現在得到錯誤是這樣的: 在上下文指定的非布爾型,其中一個條件是預期的,鄰近「和」的表達式。
先生,我想最後24小時的數據,所以,我這樣做? – user3106114