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 ?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a dead lock in oracle?

602


Explain the difference between a procedure and a function?

563


What are the types of trigger in oracle?

581


What is merge in oracle?

572


What is oracle open database communication (odbc)?

565






What is a dynamic performance view in oracle?

615


What are the restrictions in a oracle read only transaction?

576


How to insert a record into a table?

648


How to create a new table by selecting rows from another table?

561


What is an oracle database?

615


what is normalisation?what are its uses?

1769


If a parameter is used in a query without being previously defined, what diff. exist betw. report 2.0 and 2.5 when the query is applied ?

1805


How to get maxsal , minsal, ename department wise in single query

1030


What is a proxy object?

590


What happens in oracle commit?

576