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 are system versioned tables?

553


What are pl/sql cursor exceptions?

573


differentiate between float and double. : Sql dba

561


Which is better join or inner query?

518


What is substitution variable in pl sql?

505






Define select, insert, create, delete, update, drop keywords

600


Does sql between include endpoints?

554


What makes a good primary key?

524


Is merge a dml statement?

524


What are sql indexes?

545


What does (+) mean in sql joins?

528


Can we use update in sql function?

583


How much does sql certification cost?

548


How show all rows in sql?

614


How to rename a column in the output of sql query?

539