suppose we have values like 1 5 7 in a colum.Now we want
numbers like(2 3 4 6) that exists between 1 5 7.How can we
do this using sql query??

Answer Posted / krishna

This Query shall do the trick.

SQL> desc a;
Name Null? Type
------------------------------- -------- ----
A NUMBER(2)

SQL> select * from a;

A
---------
1
5
7

SQL> select x from (
2 select rownum x from all_tables ) a, (select max(a)
mx, min(a) mi from a) b

3 where a.x between b.mi and b.mx
4 and a.x not in (select * from a)
5 /

X
---------
2
3
4
6

SQL>

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between jpql and sql?

784


Why is stored procedure faster than query?

701


What are procedures used for?

703


How do you determine the current isolation level? : Transact sql

752


How many sql statements are used?

748






how many values can the set function of mysql take? : Sql dba

722


How do I start sql from command line?

707


What is rank () in sql?

700


What is the difference between sql and t sql?

717


What is dbo in sql?

706


Is sql a case sensitive language?

706


how to extract a unit value from a date and time? : Sql dba

733


How do you use collections in procedure to return the resultset?

2000


What is the purpose of the sql select top clause?

738


Define implicit and explicit cursors.

811