PipBoy2000
PipBoy2000

Reputation: 440

MSSQL database query translate given values

I have simple MSSQL query:

SELECT tw_todo as td FROM tw__work

where td gives me bit values like T or F (True/False).

Is there a way to translate this values to 1 or 0 inside this query?

Upvotes: 0

Views: 51

Answers (2)

Sagar Gangwal
Sagar Gangwal

Reputation: 7965

SELECT CASE WHEN tw_todo = 'T' THEN 1 ELSE 0 END as td FROM tw__work

Try above query.

Here I had used CASE WHEN which will convert 'T' and 'F' to 1 and 0

Upvotes: 2

KtX2SkD
KtX2SkD

Reputation: 752

SELECT CASE tw_todo WHEN 'T' THEN 1 WHEN 'F' THEN 0 ELSE 0/0 END as td FROM tw__work

Upvotes: 1

Related Questions