I'm trying to run the below query using an Excel Workbook as a data source, but I don't get why the COALESCE function won't work. Is there anything wrong with the query or the COALESCE function doesn't work with Excel?
SELECT COALESCE([net value], 0)
FROM [sheet1$a1:e6]
WHERE [units] = 'UN03'
UNION ALL
SELECT COALESCE([net value], 0)
FROM [sheet1$a1:e6]
WHERE [units] = 'UN06'
UNION ALL
SELECT COALESCE([net value], 0)
FROM [sheet1$a1:e6]
WHERE [units] = 'UN04'
UNION ALL
SELECT COALESCE([net value], 0)
FROM [sheet1$a1:e6]
WHERE [units] = 'UN02'
UNION ALL
SELECT COALESCE([net value], 0)
FROM [sheet1$a1:e6]
WHERE [units] = 'UN01'
It seems that the only thing works is the query below, but I can't return the output as the IFF function only accepts values inside single quotes, for example, 'true', 'false'. I'm trying to return these values sheet1$
.net value
, '0', the sheet1$
.net value
contains the query output and the 0 is an indication the query didn't return anything. Can anyone tell what I'm doing wrong?
SELECT IIF(Count(`sheet1$`.`net value`) > 0, `sheet1$`.`net value`, '0') AS
'Net Value'
FROM `sheet1$` `Sheet1$`
WHERE ( `sheet1$`.f1 = 'UN03' )