Hi,
Version: 4.2.8.2
Build ID: 420m0(Build:2) on Linux
Using the embedded SQL engine
I have a table in Base, with several columns, one is defined as Time and has data in the format hh:mm:ss. I’m trying to write a query that will add a calculated column with the values 1, 2, 3, or 4, depending on the time in the time-defined column (say 1 am to 5 am, 5 to noon, noon to 6 pm 6 to 1 am). For now, I’m just testing a single case, and here’s the syntax I’m using:
SELECT “key”, “day”, “TOD”, “value” , CASEWHEN (“TOD” Between “01:00:00” and “05:00:00”, 1, 0) FROM “tblMeterReading”
Here’s the error I’m getting:
SQL Status: HY000
Error code: 1000
syntax error, unexpected $end, expecting BETWEEN or IN or SQL_TOKEN_LIKE
I’m pretty sure this has to do with how I enter the time values, but I’ve tried single quotes, hash, no quotes, double quotes, and the error is the same.
What am I missing? Sounds like it should be simple enough… Thanks in advance!
UPDATE:
I’ve just tried the following:
SELECT “key”, “day”, “TOD”, “value” , CASEWHEN (“TOD” BETWEEN Time(“01:00:00”) AND Time(“05:00:00”), “1”, “0”) AS “Order” FROM “tblMeterReading”
Same error.
I know I’m stuck on something really basic, and I can’t figure it out. Your help is appreciated.