I have two views like below
create view penord1_view
as
select
ser, docno, pcode, barcode, pname, unid, unit, qty, rate
from
sale
where
tc = 'O01' and docdt > @xdate1 and docdt < @xdate2
union
select
sser as ser, sdocno as docno, pcode, barcode, pname, unid, unit, qty, rate
from
sale
where
tc = 'P01' and docdt > @xdate1 and docdt < @xdate2
and the second one is
create view penord_view
as
select
ser, docno, pcode, barcode, pname, unid, unit, rate,
SUM(qty) AS qty
from
penord1_view
group by
ser, docno, pcode, barcode, pname, unid, unit, rate
The problem is that I cannot pass @xdate1 parameter in the first view.
Please suggest how to do this in a view or in some other way in SQL Server
docdtfield from the first view and addWHEREstatement in the second viewdocdt, filter by it and then don't include it inGROUP BYor SUM