Hi Monika.....
Try This
declare @FromDate as DateTime
declare @ToDate as DateTime
declare @Location as varchar(20)
set @FromDate = (select DocDate from oinv t0 where t0.docdate='[%0]')
set @ToDate = (select DocDate from orin t0 where t0.docdate='[%1]')
select distinct InvoiceDate,WhsCode,WhsName,CustomerName,DeliveryDate,Destination,CustomerPO,DeliveryTicket,CarorTruck,
LbsLoaded,TnsLoaded,ProductCode from (
SELECT T0.[DocDate] InvoiceDate,
T2.[WhsCode],T3.[WhsName], T0.[CardName] CustomerName, T2.[ShipDate]
DeliveryDate,
T2.[ShipToCode] Destination, T2.[BaseAtCard]
CustomerPO, T0.[DocNum] DeliveryTicket, T0.[TrackNo] CarOrTruck,
T2.[Quantity]*-1 LbsLoaded, T2.[Weight1]*-1
TnsLoaded, T2.[ItemCode] ProductCode
FROM OINV T0 INNER JOIN INV1 T2 ON
T0.DocEntry = T2.DocEntry INNER JOIN OITM T1 ON T1.ItemCode = T2.ItemCode
INNER JOIN OWHS T3 ON T2.WhsCode =
T3.WhsCode
union all
SELECT T0.[DocDate] InvoiceDate,
T2.[WhsCode],T3.[WhsName], T0.[CardName] CustomerName, T2.[ShipDate]
DeliveryDate,
T2.[ShipToCode] Destination, T2.[BaseAtCard]
CustomerPO, T0.[DocNum] DeliveryTicket, T0.[U_Ref3] CarOrTruck,
T2.[Quantity]*-1 LbsLoaded, T2.[Weight1]*-1
TnsLoaded, T2.[ItemCode] ProductCode
FROM ORIN T0 INNER JOIN RIN1 T2 ON
T0.DocEntry = T2.DocEntry INNER JOIN OITM T1 ON T1.ItemCode = T2.ItemCode
INNER JOIN OWHS T3 ON T2.WhsCode =
T3.WhsCode
where t2.BaseEntry is NULL
) a
where InvoiceDate >=@FromDate and
InvoiceDate<= @ToDate
Hope Helpful
Regards
Kennedy