我无法直接从oraclesql正确显示数据。
我有两张table。medarb带有meda\ U id和init条目,联系人带有meda\ U id、cont\ U类型和号码。
连续类型可以是“mt”或“ma”
我得到的是:
init type number
aaaa MT 11111111
aaaa MA 22222222
bbbb MT 33333333
bbbb MA 44444444 and so on.
我想要的是:(每个人在一条线上)
aaaa mt 11111111 ma 22222222
bbbb mt 33333333 ma 44444444 and so on.
有可能吗?
sql是这样的:
select distinct medarb.init, contacts.cont_type, contacts.number
from contacts
inner join medarb on medarb.meda_id = contacts.meda_id
order by medarb.init
谨致问候
2条答案
按热度按时间xv8emn3q1#
在这种情况下,聚合通常是有帮助的。
3ks5zfa02#
此联接的唯一列组合是什么?是init列还是type列?您可以尝试使用oracle pivot函数。
https://blogs.oracle.com/sql/how-to-convert-rows-to-columns-and-back-again-with-sql-aka-pivot-and-unpivot
谢谢