添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
谦虚好学的毛衣  ·  8 Cool things about ...·  6 小时前    · 
儒雅的豆芽  ·  Using "INSERT ON ...·  6 小时前    · 
紧张的香瓜  ·  odps ...·  2 天前    · 
温暖的领带  ·  常见问题清单·  2 天前    · 
老实的橙子  ·  Day 11 : psycopg2 操作 ...·  2 天前    · 
发呆的水煮肉  ·  project_index_v2.0_edi ...·  1 月前    · 
豁达的可乐  ·  Tableau ...·  2 月前    · 
打篮球的手术刀  ·  中国新闻·  4 月前    · 

Thanks for the question, Sushma.

Asked: January 29, 2018 - 9:33 am UTC

Last updated: January 29, 2018 - 3:47 pm UTC

Version: 10g

Viewed 1000+ times t1.actid = t2.senid and t2.denid = t2.mkid );

is resulting data in

dbid       askid         amid
================================
d1           m1            a1




but expected out put is

SOURCE_ID    DEST_ID
========================
m1             d1
a1             d1


I browsed may web sites and found that unpivot will perform the similar kind of operations. So, tried unpivot but that did not fetch us expected results.

select DEST_ID,SOURCE_ID from 
    (select        
    t1.id as dbid,
    t2.mid as askid,
    t3.m2idd as amid from
    table1 t1, table2 t2, table3 t3 where
    t1.actid = t2.senid
    and t2.denid = t2.mkid
    unpivot INCLUDE NULLS (SOURCE_ME_GUID FOR DEST_ME_GUID IN (amid, askid));


Please suggest on this.

Regards,
Sushma

and Chris said...

The same way as a regular query:

List out the column you want in your select clause!

Dbid isn't in your unpivot clause. So it's still a column in your result set. Include that and exclude the generated dest_id:

select dbid, SOURCE_ID 
from (
  select 'd1' dbid, 'm1' askid, 'a1' amid
  from   dual
) unpivot INCLUDE NULLS (
  SOURCE_ID FOR DEST_ID IN (amid, askid)
DBID   SOURCE_ID   
d1     a1          
d1     m1  

Rating

(2 ratings)
Is this answer out of date? If it is, please let us know via a Comment Raw seems fine to me:

select dbid, SOURCE_ID 
from (
  select hextoraw('d1') dbid, hextoraw('f1') askid, hextoraw('a1') amid
  from   dual
) unpivot INCLUDE NULLS (
  SOURCE_ID FOR DEST_ID IN (amid, askid)
DBID   SOURCE_ID   
D1     A1          
D1     F1  


Sooo....

Give us a test case! i.e.

- create table
- insert into
- your query