select eid, pid,
case when i_flag='Y' and i_deleted='Y' then 'Y' else 'N' end
from test_emp
where desig in ('it','hr','account')
group by eid, pid,
case when i_flag='Y' and i_deleted='Y' then 'Y' else 'N' end;
现在我想将列i_status更新为' Y'当i_flag =' Y'和i_deleted =' Y'然后' Y'别的' N'结束 来自test_emp desig in(' it',' hr',' account') 小组,开发,pid, 当i_flag =' Y'和i_deleted =' Y'然后' Y'别的' N'结束;
我的更新stmt无效: -
update t1
set t1.i_status=t2.result
(case when i_flag='Y' and i_deleted='Y' then 'Y' else 'N' end;
from test_emp t1 ,test_emp t2
inner join t on t1.eid=t2.eid
where t1.desig in ('it','hr','account')
group by t1.eid, t1.pid,
case when t1.i_flag='Y' and t1.i_deleted='Y' then 'Y' else 'N' end);
答案 0 :(得分:0)
不知道你想做什么,但这是我最好的猜测。这当然是100%未经测试,因为我们没有表格或数据可供使用。我会建议在发布您的下一个问题之前查看这篇文章。 http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/
update e
set i_status = case when i_flag='Y' and i_deleted='Y' then 'Y' else 'N' end
from test_emp e
where desig in ('it','hr','account')