如何把不同语句查询到的字段合成一行

Dreamsly 2010-06-30 07:40:21

--查询到 pac_period_id 期间
select pac_period_id from
(
select cpp.pac_period_id,cpp.period_name
from cst_pac_periods cpp
where cpp.legal_entity = 102
order by cpp.pac_period_id desc)
where rownum=1 ;

--查询到material_id,material_price物料编码和价格
select tpam.material_id
,tpam.material_price
from tg_purchase_acc_materials tpam
where tpam.material_desc = '银'
and tpam.status = 'Active';
-- status ENTRY 状态情况

如何把这四个字段汇集到一张表中,形成一行数据
...全文
120 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dreamsly 2010-07-01
  • 打赏
  • 举报
回复
可行了,谢谢各位了
Dreamsly 2010-06-30
  • 打赏
  • 举报
回复
但这里不能使用sum或是Max,没有其他的方法吗
lzbbob1985 2010-06-30
  • 打赏
  • 举报
回复

[Quote=引用 3 楼 quiettown 的回复:]
当然如果两个结果集都只有一行,你可以使用上面合并后的结果集用SUM或MAX得到一行数据。
[/Quote]

正解
搞怪的索引 2010-06-30
  • 打赏
  • 举报
回复
创建视图!
quiettown 2010-06-30
  • 打赏
  • 举报
回复
当然如果两个结果集都只有一行,你可以使用上面合并后的结果集用SUM或MAX得到一行数据。
quiettown 2010-06-30
  • 打赏
  • 举报
回复
需要用空列和UNION ALL,没有关键项关联,不能合并行。LIKE
select 1, null 2, null 3
from t1
union all
select null 1, 2, 3
from t2
siakang 2010-06-30
  • 打赏
  • 举报
回复
--查询到 pac_period_id 期间
select pac_period_id from
(
select cpp.pac_period_id,cpp.period_name
from cst_pac_periods cpp
where cpp.legal_entity = 102
order by cpp.pac_period_id desc)
where rownum=1 ;

union all

--查询到material_id,material_price物料编码和价格
select tpam.material_id
,tpam.material_price
from tg_purchase_acc_materials tpam
where tpam.material_desc = '银'
and tpam.status = 'Active';
-- status ENTRY 状态情况

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧