日期:2014-05-17  浏览次数:20826 次

这两条sql语句怎么合并?
1,select ta.a from ta where ta.b='001';
2, select ta.a from ta where ta.b='002';

要实现如下的效果:
001,002


注意,不是这样的效果:
001,
002.

也就是说,一条结果包含两个字段,是由不同查询条件得到的。


------解决方案--------------------
select a.a||','||b.a
from (

select ta.a from ta where ta.b='001') a,( 
 select ta.a from ta where ta.b='002') b

------解决方案--------------------
SQL code
select (select ta.a from ta where ta.b='001'),(select ta.a from ta where ta.b='002')
from dual;