我正在尝试计算 SQL Server 2008 中两个日期之间状态为 0 的记录有我的程序,但它不是正确的 trows 错误。
消息 156,级别 15,状态 1,过程 sp_SerchPickupHispanicBetweenDates,第 6 行
关键字“between”附近的语法不正确。
程序看起来像
CREATE procedure sp_SerchPickupHispanicBetweenDates
@date1 date,
@date2 date
as
select COUNT ( Pickuphispanic ) from pickup
where Pickuphispanic = 1 and pickupdate like between @date1+ '%' and @date1 +'%'
正在尝试在互联网上搜索解决方案,但没有成功。任何想法如何纠正它?我也有完美的选择语句
select COUNT ( Pickuphispanic ) from pickup
where Pickuphispanic = 1 and pickup.pickupdate between '2006-07-01' and '2010-12-31'