It's all about the answers!

Ask a question

if else condition in RRDI query


Naveen Chandani (4812022) | asked Jul 01 '12, 1:08 a.m.
edited Nov 28 '13, 2:36 a.m. by Krzysztof Ka┼║mierczyk (7.4k35499)
I have 2 columns in a query in RRDI (column a & column b). i want to insert a data item with the if else condition. The condition is if the value in column a is equal to column b then print no change else print the value of column a itself. Can you please help me with the syntax of this if else condition.I am facing difficulty with the else statement. It is not allowing me to print the value of column a. However if I enter some string over there, it works fine.

2 answers



permanent link
Anderson Oliveira Pinto (1701717) | answered Jul 31 '12, 5:01 p.m.
Hi Naveen Chandani,

You must to observe what kind of data you are printing.

For example:

     if the column A is a string


if (column A = column B) then ('1') else (column A)

    if the column A is integer

if (column A = column B) then (1) else (column A)


Note the quotes when you use a string column.



Comments
Naveen Chandani commented Aug 01 '12, 2:20 a.m.

How about a date comparison?


Anderson Oliveira Pinto commented Aug 01 '12, 10:56 a.m.

Try this

if ([Creation Date] > '01/01/2012') then ('01/01/2012') else ([Creation Date])

make sure that the date printed is a valid date


permanent link
Anderson Oliveira Pinto (1701717) | answered Aug 01 '12, 10:58 a.m.
Try this

if ([Creation Date] > '01/01/2012') then ('01/01/2012') else ([Creation Date])

make sure that the date printed is a valid date

Your answer


Register or to post your answer.