Home » SQL & PL/SQL » SQL & PL/SQL » How to get this SQL output (2):- (Sql Plus 10g)
How to get this SQL output (2):- [message #597969] Wed, 09 October 2013 08:26 Go to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

Q2). I have three tables Emp,E_Cou and E_con_desc

Emp:-
CODE  CODE1  CODE2
101    201    301
102    202    302
103    203    303
104    204    304


E_Cou:-
E_CODE
101
102
103
104
201
202
203
204
301
302
303
304


E_con_desc:-
E_CODE  E_DECS
101       A
102       B
103       C
104       D
201       E
202       F
203       G
204       H
301       I
302       J
303       K
304       L


and I Require Output as:-

CODE1   DESC1   CODE2   DESC2  CODE3  DESC3
101      A       201     E      301    I
102      B       202     F      302    J
103      C       203     G      303    K
104      D       204     H      304    L
icon8.gif  Re: How to get this SQL output (2):- [message #597973 is a reply to message #597969] Wed, 09 October 2013 08:32 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

And maybe some explanations and create table and insert statements will help.
Maybe also some feedback and thanks in your previous topic will do too.

Re: How to get this SQL output (2):- [message #597977 is a reply to message #597973] Wed, 09 October 2013 08:39 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
What is with a one column table?
Ever learn about data normalization?
If no, then maintain 2 meter separation from any keyboard until you learn & embrace Third Normal Form.
Re: How to get this SQL output (2):- [message #597980 is a reply to message #597969] Wed, 09 October 2013 08:48 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

SQL> with
  2    emp as (
  3     select 101 code, 201 code1, 301 code2 from dual union all
  4     select 102,    202,    302 from dual union all
  5     select 103,    203,    303 from dual union all
  6     select 104,    204,    304 from dual 
  7    ),
  8    E_con_desc as (
  9      select 101 e_code,  'A' e_decs from dual union all
 10      select 102,       'B' e_decs from dual union all
 11      select 103,       'C' e_decs from dual union all
 12      select 104,       'D' e_decs from dual union all
 13      select 201,       'E' e_decs from dual union all
 14      select 202,       'F' e_decs from dual union all
 15      select 203,       'G' e_decs from dual union all
 16      select 204,       'H' e_decs from dual union all
 17      select 301,       'I' e_decs from dual union all
 18      select 302,       'J' e_decs from dual union all
 19      select 303,       'K' e_decs from dual union all
 20      select 304,       'L' e_decs from dual
 21    )
 22  select e.code code1, d1.e_decs desc1,
 23         e.code1 code2, d2.e_decs desc2,
 24         e.code2 code3, d3.e_decs desc3
 25  from emp e, E_con_desc d1, E_con_desc d2, E_con_desc d3
 26  where d1.e_code = e.code
 27    and d2.e_code = e.code1
 28    and d3.e_code = e.code2
 29  /
     CODE1 D      CODE2 D      CODE3 D
---------- - ---------- - ---------- -
       101 A        201 E        301 I
       102 B        202 F        302 J
       103 C        203 G        303 K
       104 D        204 H        304 L

Re: How to get this SQL output (2):- [message #597982 is a reply to message #597980] Wed, 09 October 2013 09:10 Go to previous messageGo to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

thanks, able to understand this one but still facing trouble in previous topic(partition by).
Re: How to get this SQL output (2):- [message #597993 is a reply to message #597982] Wed, 09 October 2013 11:53 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
jgjeetu wrote on Wed, 09 October 2013 19:40
thanks, able to understand this one but still facing trouble in previous topic(partition by).


That was SUM function used as an Analytic function with PARTITION BY clause in your previous topic. If you find difficulty in that thread, you should have mentioned it. You are lucky enough that people are pointing you to documentation links which are, strictly speaking, mandate for anybody to read and understand the basics.

Learn and share, basic principle to grow in any field.

Regards,
Lalit

[EDIT : Fixed typo errors]

[Updated on: Wed, 09 October 2013 11:56]

Report message to a moderator

Re: How to get this SQL output (2):- [message #597999 is a reply to message #597993] Wed, 09 October 2013 12:58 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
[quote title=Lalit Kumar B wrote on Wed, 09 October 2013 17:53]jgjeetu wrote on Wed, 09 October 2013 19:40

That was SUM function used as an Analytic function with PARTITION BY clause in your previous topic. If you find difficulty in that thread, you should have mentioned it.
He did, several hours ago. Michel responded and OP responded back saying that he now has the appropriate document section to read. If you are going to pull someone up for their posts, take the time to read the posts involved and (in this instance) pay particular attention to the time stamps on each post.
Re: How to get this SQL output (2):- [message #598002 is a reply to message #597999] Wed, 09 October 2013 13:10 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
[quote title=pablolee wrote on Wed, 09 October 2013 23:28]Lalit Kumar B wrote on Wed, 09 October 2013 17:53
jgjeetu wrote on Wed, 09 October 2013 19:40

That was SUM function used as an Analytic function with PARTITION BY clause in your previous topic. If you find difficulty in that thread, you should have mentioned it.
He did, several hours ago. Michel responded and OP responded back saying that he now has the appropriate document section to read. If you are going to pull someone up for their posts, take the time to read the posts involved and (in this instance) pay particular attention to the time stamps on each post.


My mistake, I should have read other posts before responding here. Apologies.
Re: How to get this SQL output (2):- [message #598007 is a reply to message #598002] Wed, 09 October 2013 13:22 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Lalit Kumar B wrote on Wed, 09 October 2013 19:10


My mistake, I should have read other posts before responding here. Apologies.

Don't apologise to me, I'm not the one that you incorrectly pulled up.
Re: How to get this SQL output (2):- [message #598093 is a reply to message #598007] Thu, 10 October 2013 07:41 Go to previous message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

I have seen Everyone here always remain ready to help so No need to say sorry lalit Its Ok. Smile
Previous Topic: Dynamic Table Partitioning
Next Topic: date conversion format issue
Goto Forum:
  


Current Time: Thu Apr 25 12:37:04 CDT 2024