Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3257

help adding date range variables to query

$
0
0

Hello All,

 

i'm having an issue adding a date range into the following query:

 

SELECT

 

T0.[Cust],

T2.cardname,

T1.slpname,

SUM(T0.[line sales]) as [Total Sales £],

SUM(t0.Grosprofit) as [Gross Profit £],

ROUND(Sum(T0.[GrosProfit]) / Sum(t0.[Line Sales])*100.0,2) as 'GP%'

 

FROM

 

dbo.Allpack_GP_View T0

INNER JOIN OSLP T1 on T0.Slpcode = T1.Slpcode

INNER JOIN OCRD T2 ON T0.Cust = T2.cardcode

 

WHERE 

 

(SELECT MIN(T20.[DocDate]) FROM [dbo].OINV T20 WHERE T20.CardCode = T0.[Cust] GROUP BY T20.[CardCode] ) >= '[%1]' and

(SELECT MIN(T20.[DocDate]) FROM [dbo].OINV T20 WHERE T20.CardCode = T0.[Cust] GROUP BY T20.[CardCode] ) <= '[%2]' and

T1.Slpname = [%0] AND

T0.[Line sales] > 0 

 

GROUP BY

 

T0.[cust],

T2.cardname, T

1.slpname

 

I'm getting the following error when i run that query:

 

Cannot drop the table '#temp_oitt_fathers0', because it does not exist or you do not have permission

 

Any idea's how I could fix this?


Viewing all articles
Browse latest Browse all 3257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>