If I have a select statment which retrives 2 rows, & that
rows have the same data in all the fields except the last
field and I want to merge the 2 rows to be in 1 row with
concatenating the last field which have the different
data.... eg: the 1st row has these fields: A-B-C
the second row has: A-B-X ........ i want to merge the two
row to be in one row like ----> A- B- C,X

Answers were Sorted based on User's Feedback



If I have a select statment which retrives 2 rows, & that rows have the same data in all the f..

Answer / murali mohan

Try this...Hope this will give the Required Answer
create table testsamp(a char,b char,c char);
insert into testsamp values ('A','B','C');
insert into testsamp values ('A','B','X');

select a,b,c from(
select a , b,
c||lead(c,1) over (partition by a,b order by a,b) c from
testsamp ) tmp where rownum=1;

Regards,
Murali

Is This Answer Correct ?    4 Yes 1 No

If I have a select statment which retrives 2 rows, & that rows have the same data in all the f..

Answer / sreeharibabu g

select max(a),max(b),listagg(c,',') within group ( order by null) from testsamp group by a,b;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

What is meant by redo log buffer ?

2 Answers  


What are the different approaches used by Optimizer in choosing an execution plan ?

2 Answers  


What is the effect of setting the 'RULE' for OPTIMIER_GOAL parameter of the ALTER SESSION Command ?

1 Answers  


What are various constraints used in SQL?

1 Answers   Polaris,


what are the things that you consider while creating indexes on partitioning tables?

1 Answers  






Can we store pictures in the database and if so, how it can be done?

0 Answers  


what is the difference between rollback & commit? can a foreign key has null value?

6 Answers  


what are the differen between key flexifild and discriptive fiexifild.

1 Answers  


what is the syntax of update command?

3 Answers   Semantic Space,


What is a subquery?

0 Answers  


What is the maximum limit on the number of columns in a table?

0 Answers  


what is null value?

9 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)