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 / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens to the indexes if a table is recovered?

583


What is raw datatype?

597


How do you bind variables in oracle?

555


What privilege is needed for a user to delete rows from tables in another schema?

570


What are the different types of modules in oracle forms?

568






What happens internally when the user types userID/password@string in SQL PLUS Thanks-Bhaskar

3837


What are the components of logical database structure in oracle database?

589


How to grant create session privilege to a user in oracle?

574


How to declare a local variable?

606


How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com?

1477


When system tablespace is created?

612


How to count duplicated values in a column in oracle?

558


How to create a stored procedure in oracle?

583


What are the different oracle database objects?

592


What happens if variable names collide with table/column names?

589