一道面试题,求答案

[img]http://dl.iteye.com/upload/attachment/544376/ade1565c-8baf-39f1-96ea-7badc4aa50e4.jpg[/img]
具体问题如下图,求解答,谢谢!

4个回答

你这个可能是要你写一个外链接
orcle代码:
[code="sql"]
select a.id,a.name,b.type,decode(b.id,null,'N','Y') uitl from a表 a left join b表 b on a.id=b.id;
[/code]

sql2005
orcle代码:
[code="sql"]
select a.id,a.name,b.type,case when b.id is null then 'N' else 'Y' end uitl from a表 a left join b表 b on a.id=b.id;
[/code]

[code="sql"]select a.id,a.name,b.type,(case when exists a.id=b.id then 'Y' else 'N') from a left join b on a.id=b.id;[/code]

不知是否正确啊

[code="sql"]select a0.name,(case when b0.type is null then N else Y) from a as a0,b as b0 where a0.ID=b0.id[/code]

这样应该是对的。

[code="java"]select a.id,a.name,b.type,(case when b.type is null then 'N' else 'Y') from a表 a,b表 b where a.id = b.id[/code]

立即提问
相关内容推荐