开发者

Get Names from Values in a select statement + Sql server 2005

开发者 https://www.devze.com 2022-12-21 11:35 出处:网络
Here is my query Select Gender from Table The result pane shows 1开发者_StackOverflow社区 1 1 2 2 But i want the results to be

Here is my query

Select Gender from Table

The result pane shows

1

开发者_StackOverflow社区 1

1

2

2

But i want the results to be

Male

Male

Male

Female

Female

The names Male and Female wont be present in my database.... I want to just hardcode the names based on values from the select statement....


try

Select case WHEN Gender=1 THEN 'Male' ELSE 'Female' end Gender  from Table
0

精彩评论

暂无评论...
验证码 换一张
取 消