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 are the predefined tablespaces in a database?

556


How can I get column names from a table in oracle?

538


What are privileges and grants?

574


What are the differences between char and nchar in oracle?

603


What is the recommended interval at which to run statspack snapshots, and why?

2437






How to count duplicated values in a column in oracle?

554


Explain the use of constraints option in exp command.

566


Explain the difference between sap and oracle?

577


How to connect ms access to oracle servers?

552


What is Reduced List of Values?

1708


How do you store pictures in a database?

563


How to view existing locks on the database?

553


How to create a server parameter file?

574


List the various oracle database objects?

602


Can any one explain me when i execute below query.. select months_between('07-JUL-12','10-FEB-12') from dual; Out put:- 4.90322581 How oracle calculate?

935