We need to compare two successive records of a table based
on a field. For example, if the table is CUSTOMER, and the
filed is Account_ID, To compare Account_IDs of record1 and
record2 of CUSTOMER table, what can be the query ?

Answers were Sorted based on User's Feedback



We need to compare two successive records of a table based on a field. For example, if the table i..

Answer / garima

SELECT (case when a_id > b_id then 'Greater' else 'Lesser'
end), a_id, b_id
FROM (SELECT ROWNUM r_a, account_id a_id
FROM customer) a,
(SELECT ROWNUM r_b, account_id b_id
FROM customer) b
where r_a = r_b+1;

Is This Answer Correct ?    1 Yes 0 No

We need to compare two successive records of a table based on a field. For example, if the table i..

Answer / suman rana

select * from
(SELECT account_id , lead(account_id, 1, 0) over (order by
1) nxt_account_id FROM customer)
where account_id = nxt_account_id

Is This Answer Correct ?    0 Yes 0 No

We need to compare two successive records of a table based on a field. For example, if the table i..

Answer / manikandan. s

WITH wt AS
(SELECT ROWNUM sl, a.Account_ID
FROM CUSTOMER a)
SELECT a1.*
FROM wt a1, wt a2
WHERE a1.sl = a2.sl + 1 AND a1.col1 = a2.col1
UNION
SELECT a2.*
FROM wt a1, wt a2
WHERE a1.sl = a2.sl + 1 AND a1.col1 = a2.col1

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Oracle General Interview Questions

select to_char('10','10') from dual This gives me an error oRA-1481 INVALID NUMBER FORMAT MODEL why? pls help

6 Answers  


How many data types are supported?

0 Answers  


how to get the no employee in each department including the dept which has 0 employee

5 Answers  


how to produce numbers from 1 to 10 using dual table

4 Answers   Genpact,


What is difference between SUBSTR and INSTR?

1 Answers  






What suggestions do you have to reduce the network traffic?

0 Answers  


I have a table emp. There is only one column in the table. In that , there are only three rows in that column. The value in the first row is 'A' and the value in the second row is 'B' and the third row is 'C'. Now, my question is , How will you write a select query to display the output as B C A Note: order by cannot be used coz it gives us output as CBA. But the output should be BCA.

4 Answers  


How to get a create statement for an existing table?

0 Answers  


what is the difference between authorization and authentication?

4 Answers   MAHINDRA, PUCIT,


17. Display the order number and average item cost for each order.

1 Answers   Wipro,


How do I learn what codesets are available in oracle?

0 Answers  


How to update values in a table in oracle?

0 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)