表名为 people 字段为ID name sex1 张某某 1我想通过case语句 将查询到的结果为 张某某(男) 请问语句该怎么写啊
成功了,还有一个问题ID name sex date1 张某某 1 2015-01-01如果是男生的话 查询到的结果为 张某某(2015-01-01)
select name+( case when sex=1 then '('+date+')' else '' end)from people如果你的date是datetime类型,可能会有问题改成cast(date as varchar(10))