I'm getting an error when try to run this SQL code:
SQL Server Database Error: Must declare the scalar variable "@ParamDate"
I can't see where the error is. Anyone have suggestions? Thank you.
delcare @ParamDate smalldatetime
set @ParamDate = '2013-10-15'
select count(s.SERIAL_NUMBER) as TOTAL_QTY,
sum(case when s.TRANS_TYPE = 'BUILD' then 1 else 0 end) as BUILD_QTY,
sum(case when s.TRANS_TYPE = 'REBUILD' then 1 else 0 end) as REBUILD_QTY,
sum(case when s.TRANS_TYPE = 'SCRAP' then 1 else 0 end) as SCRAP_QTY,
from S_TRANS s
s.org = '100'
and s.TRANS_TYPE in ('BUILD', 'REBUILD', 'SCRAP')
and ms.TRANSACTION_DATE between dateadd(hour, 7, @ParamDate) and dateadd(hour, 29, @ParamDate)
group by m.PC, m.USER_ID