Hi,
I'm not sure I understand.
We have the following:
Declare @FromDate Datetime
Declare @ToDate Datetime
declare @Slp as nvarchar(20)
Set @FromDate = (Select min(t0.Docdate) from dbo.ORDR t0 where t0.Docdate >='[%1]')
Set @ToDate = (Select max(t0.Docdate) from dbo.ORDR t0 where t0.Docdate <='[%2]')
set @slp = (select max(T2.[SlpName]) from OSLP t2 where T2.[SlpName] = '[%3]')
Select [C] as Customercode, [S] as SalesEmp,isnull([EDI],0) as EDI,isnull([EMAIL],0) as EMAIL,isnull([FAX],0) as FAX,isnull([HEAD OFFICE],0) as 'HEAD OFFICE',isnull([MAJOR],0) as MAJOR,isnull([MINISELL],0) as MINISELL,isnull([OPEN SHOWROOM],0) as 'OPEN SHOWROOM',isnull([PHONE],0) as PHONE,isnull([STAFF PURCHASE],0) as 'STAFF PURCHASE',isnull([TRADE FAIR],0) as 'TRADE FAIR',isnull([WEBSITE],0) as WEBSITE
from
(
SELECT T0.[CardCode] as C, T1.[SlpName] as S,sum(T0.[DocTotal]) as T, T0.[U_OrderSource] as P FROM ORDR T0 INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode WHERE T0.[DocDate] between @fromdate and @todate and T1.[SlpName] = @Slp GROUP BY T0.[CardCode], T1.[SlpName],T0.[U_OrderSource] ) S
Pivot
(sum(t) FOR P in ([EDI],[EMAIL]),[FAX],[HEAD OFFICE],[MAJOR],[MINISELL],[OPEN SHOWROOM],[PHONE],[STAFF PURCHASE],[TRADE FAIR],[WEBSITE])) P
And when I try to run it in SAP B1 it comes up with the error:
It says - Incorrect Syntax near ',' - user defined values could not be prepared.
Any more thoughts on this?
Regards
Rick