Question : SQL return a boolean on evaluation of an existing field.

I have a table (Table1) in my MSSQL which coontains 2 columns:  Name and Title.  I need a query to return the Name and a boolean value designating whether Title has a length.  In other words, if Title is "", then I need a zero or false and otherwise a 1 or true.  After that I need to order the return results by this boolean value.

SELECT Name, (Len(Title) = 0) AS boolValue FROM Table1 ORDER BY boolValue;

I may need to somehow evaluate and cast the expression above, but obviously I am not doing it right.

Thank you.

Answer : SQL return a boolean on evaluation of an existing field.

Sorryy,


SELECT Name,
 CASE WHEN Len(ISNULL(Title,'')) =0  THEN  0  ELSE 1 END AS boolValue
FROM Table1 ORDER BY boolValue;

Random Solutions  
 
programming4us programming4us