用完case when后取别名,写参数是未明确定义列,该怎么获取这一列呢
SQL贴完
-------
方法1;
select (case when set=0 then '男' else '女' end) [SEX_] from table WHERE (case when set=0 then '男' else '女' end)='男'
方法2
SELECT * FROM (
select (case when set=0 then '男' else '女' end) [SEX_] from table
) T WHERE T.SEX_='男'
外面在嵌套一层SQL
写过了条件
直接
select * from table where (case when zd >1 then '2' else zd end)=2