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

Does mysql support pl sql?

636


how to use case expression? : Sql dba

561


What is rename command in sql?

475


How many times can we commit in a loop?

578


Is primary key a clustered index?

545






Can a view be mutating? If yes, then how?

586


How do I view a table in sql?

551


Can we use loop in sql?

544


What are some predefined exceptions in pl/sql?

561


How do I write a cron which will run a sql query and mail the results to agroup?

533


how to check myisam tables for errors? : Sql dba

621


What is sqlerrd?

540


How can we debug in PL/SQL?

671


what is the use of set statement in tsql? : Transact sql

546


What is the difference between mdf and ndf files?

581