Home » SQL & PL/SQL » SQL & PL/SQL » Need a Query to solve this
Need a Query to solve this [message #420896] Thu, 03 September 2009 02:20 Go to next message
bond007
Messages: 58
Registered: March 2009
Member

Hi friends need your help to write a SQL query for the below requiremnt .
TABLE1

E_NAME V1 V2 V3 V4 V5 V6
ALEX    6 2  3  4  1  5
EMILY   2 6  3  4  5  1

WE HAVE TO INSERT DATA INTO TABLE2


E_NAME  S1  S2  S3  S4  S5  S6
ALEX    V5  V2  V3  V4  V6  V1
EMILY   V6  V1  V3  V4  V5  V2

TABLE1 will tell the positions of table2 where the values (V1 V2 V3 V4 V5 V6) ll be inserted.

Re: Need a Query to solve this [message #420897 is a reply to message #420896] Thu, 03 September 2009 02:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Post a working Test case: create table and insert statements along with the result you want with these data.

Regards
Michel
Re: Need a Query to solve this [message #420898 is a reply to message #420897] Thu, 03 September 2009 02:43 Go to previous messageGo to next message
bond007
Messages: 58
Registered: March 2009
Member

create table table1(
 E_NAME  varchar2(26),
 V1  number(2),
 V2  number(2),
 V3  number(2),
 V4  number(2),
 V5  number(2),
 V6  number(2));

insert into table1 values ('ALEX ',6, 2,3,4,1,5);
insert into table1 values ('EMILY',2, 6,3 ,4,5,1);


Re: Need a Query to solve this [message #420901 is a reply to message #420898] Thu, 03 September 2009 03:08 Go to previous message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> select e_name,
  2         decode(v1,1,'V1')||decode(v2,1,'V2')||decode(v3,1,'V3')||
  3           decode(v4,1,'V4')||decode(v5,1,'V5')||decode(v6,1,'V6') s1,
  4         decode(v1,2,'V1')||decode(v2,2,'V2')||decode(v3,2,'V3')||
  5           decode(v4,2,'V4')||decode(v5,2,'V5')||decode(v6,2,'V6') s2,
  6         decode(v1,3,'V1')||decode(v2,3,'V2')||decode(v3,3,'V3')||
  7           decode(v4,3,'V4')||decode(v5,3,'V5')||decode(v6,3,'V6') s3,
  8         decode(v1,4,'V1')||decode(v2,4,'V2')||decode(v3,4,'V3')||
  9           decode(v4,4,'V4')||decode(v5,4,'V5')||decode(v6,4,'V6') s4,
 10         decode(v1,5,'V1')||decode(v2,5,'V2')||decode(v3,5,'V3')||
 11           decode(v4,5,'V4')||decode(v5,5,'V5')||decode(v6,5,'V6') s5,
 12         decode(v1,6,'V1')||decode(v2,6,'V2')||decode(v3,6,'V3')||
 13           decode(v4,6,'V4')||decode(v5,6,'V5')||decode(v6,6,'V6') s6
 14  from table1
 15  order by 1
 16  /
E_NAME     S1           S2           S3           S4           S5           S6
---------- ------------ ------------ ------------ ------------ ------------ ------------
ALEX       V5           V2           V3           V4           V6           V1
EMILY      V6           V1           V3           V4           V5           V2

2 rows selected.

Regards
Michel
Previous Topic: Problem with dbms_scheduler (merged)
Next Topic: database link
Goto Forum:
  


Current Time: Wed Dec 07 03:24:47 CST 2016

Total time taken to generate the page: 0.13621 seconds