Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boolean expression as column value in transact sql

In most RDBMS:es, this work:

select (5 > 3)

and evaluates to true. It doesn't work in MS Transact SQL and the only workaround I've found is to write:

select case when 5 > 3 then 1 else 0 end

Which kind of sucks because it is much more verbose. Is there a better way to write the above kind of checks?

like image 204
Björn Lindqvist Avatar asked Mar 03 '11 15:03

Björn Lindqvist


1 Answers

If the problem is arithmetic comparison:

select (5 - 3)

Then at the application level test for < or = or > 0.

like image 136
Clodoaldo Neto Avatar answered Oct 26 '22 10:10

Clodoaldo Neto