...就是条件不同的2个sql,如何拼成一个sql显示出来啊
发布网友
发布时间:2024-10-19 21:55
我来回答
共5个回答
热心网友
时间:2024-11-16 17:49
select x.*,y.* from (select sum(a.total_due_amount)/1000 as long2,sum(a.duration) as time2,sum(a.Total_Due_Units) as hujiao2
from t_yd_ue_10_4710_20101005 a
where a.prod_id in ('TUN10046','TUN10047')) x,
(select sum(a.total_due_amount)/1000 as long3,sum(a.duration) as time3,sum(a.Total_Due_Units) as hujiao3
from t_yd_ue_10_4710_20101005 a
where a.prod_id in ('TUN10045')) y ;
在这个基础上加条件得到你要的,否则出来的是笛卡尔
热心网友
时间:2024-11-16 17:49
用union连接
热心网友
时间:2024-11-16 17:53
2个表数据合并
select .. FROM .. WHERE ..
UNION
select .. FROM .. WHERE ..
如果有重复的,会合并掉。
select .. FROM .. WHERE ..
UNION ALL
select .. FROM .. WHERE ..
如果有重复的,不合并掉。
热心网友
时间:2024-11-16 17:48
顶spiderrobot的
热心网友
时间:2024-11-16 17:52
select sum(a.total_due_amount)/1000 as long2,sum(a.duration) as time2,sum(a.Total_Due_Units) as hujiao2
from t_yd_ue_10_4710_20101005 a
where a.prod_id in ('TUN10046','TUN10047')
union
select sum(a.total_due_amount)/1000 as long3,sum(a.duration) as time3,sum(a.Total_Due_Units) as hujiao3
from t_yd_ue_10_4710_20101005 a
where a.prod_id in ('TUN10045') ;