0

SQL= syntax using CASE statement

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

    1 comment

    Please sign in to leave a comment.