Replacing IF with CASE

(2 posts) (1 voice)

Tags:

No tags yet.

  1. mleary2001, Member

    Hello, it's me again,

    I am trying to replace an IF statement with a CASE statement, but it looks to me like the WHEN is not recognized by the myDBR interpreter (it is not highlighted), and I get an error message.

    Here is my code:

    /* Customize bar colors */
    select
    'dbr.chart.options',
    'label_color',
    event_datetime,

    /* if (event_type='Ignition On', '0x42B64A', '0xE85854') */

    CASE event_type
    WHEN 'Ignition On' THEN '0x42B64A'
    WHEN 'Ignition Off' THEN '0xE85854'
    END CASE

    from
    rkhydro_gpsdata.asset_event_datetime_elapsed_event_type_temp_table;

    Here is the error message:

    syntax to use near 'CASE from rkhydro_gpsdata.asset_event_datetime_elapsed_event_type_t' at line 29

    Thank in advance,

    Mike

  2. mleary2001, Member

    Looks like I solved it be taking the CASE off of the end!

    Mike


Reply

You must log in to post.