Hi all,
I hope someone can help me with this. I am trying to use the following SQL-statement in a NL-function:
select sum ((case when BResTimeInvoiced <>'' then BResTimeInvoiced else BResQuantity end) * BResSellPrice) from bookedres where bresjobkey in (select jobkey from jobs where jobstatus <> 'Cancelled' and JobIsInternal=0 and jobroomkey=1 and
JobDate >= '2014-01-01' and JobDate <= '2014-09-30')
This is the function in Excel/Jet:
=nl(;"SQL=select sum ((case when BResTimeInvoiced <>'' then BResTimeInvoiced else BResQuantity end) * BResSellPrice) from bookedres where bresjobkey in (select jobkey from jobs where jobstatus <> 'Cancelled' and JobIsInternal=0 and jobroomkey=1 and JobDate >= '"& $J$8 & "'and JobDate <= '" & $J$9 & "')")
I thought the problem might be in the date-part of the formula, so I skipped this:
=nl(;"SQL=select sum ((case when BResTimeInvoiced <>'' then BResTimeInvoiced else BResQuantity end) * BResSellPrice) from bookedres where bresjobkey in (select jobkey from jobs where jobstatus <> 'Cancelled' and JobIsInternal=0 and jobroomkey=1)";;"DataSource=";$J$5)
This gives me the following error:
Does anyone know if I can get this to work?
Thanks in advance!!!!
Regards,
Gerard
Date
Votes
1 comment
-
Jet Reports Historic Posts Official comment Sorry, found the answer using some syntax fhilton posted a while ago.
I had to include an alias for the calculation and refer to this alias as the field to retreive:
=nl(;"SQL=SELECT SUM ((CASE WHEN BResTimeInvoiced <>'' then BResTimeInvoiced ELSE BResQuantity END) * BResSellPrice) AS CrewAmount FROM BookedRes WHERE BResJobKey IN (SELECT JobKey FROM Jobs WHERE JobStatus <> 'Cancelled' AND JobIsInternal=0 AND jobroomkey=1)";"CrewAmount";"DataSource=";$J$5)
Perhaps this can help someone…
Regards,
Gerard
Please sign in to leave a comment.