PostgreSql : using a statement as case condition -
when use statement case condition returns false;
select * table order (case when (true) id else 1/0 end) desc -- works select * table order (case when (select true) id else 1/0 end) desc -- exception select * table order (case when (1=1) id else 1/0 end) desc -- works select * table order (case when (select 1=1) id else 1/0 end) desc -- exception
what wrong condition?
the case when
expects boolean
result condition per documentation:
each condition expression returns boolean result.
the select
statements return relation (yes, single row having single column boolean
type , value of true
still not boolean
).
Comments
Post a Comment