Hi,
I am interested if the following sample can be done in SQL statement.
Code:
Table: TAB
ID OPERATOR COL1 COL2
------------------------------------
1 < 100 90
And many many more records.
ID is primary key of table TAB.
I would like to compare COL2 value with COL1 according to the OPERATOR.
Someting like: SELECT CASE WHEN COL2 < COL1 THEN 'GOOD' ELSE 'BAD' END FROM TAB;
but instread of specifying '<' character I would like to get that operator from OPERATOR column.
Someting like: SELECT CASE WHEN COL2 OPERATOR COL1 THEN 'GOOD' ELSE 'BAD' END FROM TAB;
But above sql returs error:
SQL0104N An unexpected token "OPERATOR" was found following "SE WHEN
COL1". Expected tokens may include: "IN". SQLSTATE=42601
Is there any way to solve this problem in SQL? Can this be done in SQL?
Thanks,
Grofaty