ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a CASE statement in another spreadsheet? (https://www.excelbanter.com/excel-programming/306618-using-case-statement-another-spreadsheet.html)

Andy

Using a CASE statement in another spreadsheet?
 
Hi,
I'm selecting from another spreadsheet via ODBC, and want to use a CASE
function in the select statement, to short cut some summing up.

Is something like this possible (heres a cut down version)?
SELECT ActualApr05, case when ActualApr05 <0 then ActualApr05 else 0 end as
QT105 FROM forecastcosts

The statement above returns the following error:
[Microsoft][ODBC Excel Driver] Syntax error (missing operator) in query
expression 'case when ActualApr05 <0 then ActualApr05 else 0 end'.

Any ideas?
Many thanks in advance

Jamie Collins

Using a CASE statement in another spreadsheet?
 
"sebastienm" wrote ...

replace the Case statement by an IIF statement, eg:
SELECT
ActualApr05,
iif( ActualApr05 <0, ActualApr05, 0) as QT105
FROM forecastcosts


I can't see the CASE statement is needed e.g. apart from being less
efficient, how is it different from

SELECT
ActualApr05, ActualApr05 AS QT105
FROM forecastcosts

?

Jamie.

--


All times are GMT +1. The time now is 07:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com