+1 vote
25 views
If need to return 1 if some values is available in table..How can do the same in query.

Like if value is greater than 0 in table then return 1
asked Mar 25, 2016 in Computer Science - IT by techdoubt | 25 views

1 Answer

+1 vote
Best answer

You can use CASE in sql query .

For Example you need to check whether a column is greater than 0 and if true take value as 1

SELECT        Col_Name, CASE WHEN tabNum > 0 THEN '1' END AS TableNum
FROM            tbl_Name

Here when tabNum is greater than 0 then you will get output as 1

answered Mar 26, 2016 by slow_learner
selected Mar 26, 2016 by techdoubt