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
what is the difference between union and union all? : Sql dba
What is difference between my sql and sql?
Are subqueries faster than joins?
what is the difference between a local and a global temporary table? : Sql dba
Is big data nosql?
How do I save the results of sql query in a file?
Determine if oracle date is on a weekend?
What is exit statement?
When is the explicit cursor used ?
What is union, minus and interact commands?
What does select * from mean in sql?
write an sql query to get third maximum salary of an employee from a table named employee_table. : Sql dba
What is the difference between database trigger and stored procedure?
What are different clauses used in sql?
How can we debug in PL/SQL?