var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Select statement - is there a limit in SQL language?
I am interested if the following sample can be done in SQL statement.
I would like to compare COL2 value with COL1 according to the OPERATOR.
ID OPERATOR COL1 COL2
1 < 100 90
And many many more records.
ID is primary key of table TAB.
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?
select case when operator = '<'
and col2 < col1 then 'good'
when operator = '<='
and col2 <= col1 then 'good'
when operator = '='
and col2 = col1 then 'good'
when operator = '>'
and col2 > col1 then 'good'
when operator = '>='
and col2 >= col1 then 'good'
when operator = '<>'
and col2 <> col1 then 'good'
else 'bad' end
Excellent!!! It works for me.
I have heard one SQL expert to say: "There is much greater change of limitation in knowledge then in SQL power".
Thank you very much,