multiple rows into one Single row [message #655137] |
Tue, 23 August 2016 00:16 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/8785574fd08b9a84ab4a26af8b99d56b?s=64&d=mm&r=g) |
tkiranr
Messages: 1 Registered: August 2016
|
Junior Member |
|
|
Hi Experts ,
How to get this one done in OBI analysis,
Candidate # , Employer Seq 1, Employer
001,1, abc
001,2,def
I want to show it as
Candidate # , Employer Seq 1, Employer1,Employer Seq 1,Employer1
001,1,abc,2,def
Thank you
|
|
|
Re: multiple rows into one Single row [message #655139 is a reply to message #655137] |
Tue, 23 August 2016 01:00 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/102589.gif) |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals, as solution depends on it.
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
SQL> with data as (
2 select deptno candidate#, row_number() over (order by null) seq, ename employer
3 from emp where deptno = 10 and rownum <= 2
4 )
5 select candidate#,
6 max(decode(seq, 1, seq)) empseq1,
7 max(decode(seq, 1, employer)) employer1,
8 max(decode(seq, 2, seq)) empseq2,
9 max(decode(seq, 2, employer)) employer2
10 from data
11 group by candidate#
12 /
CANDIDATE# EMPSEQ1 EMPLOYER1 EMPSEQ2 EMPLOYER2
---------- ---------- ---------- ---------- ----------
10 1 CLARK 2 KING
|
|
|