Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 union and union all? : Sql dba

1060


What is difference between my sql and sql?

1132


Are subqueries faster than joins?

1072


what is the difference between a local and a global temporary table? : Sql dba

1118


Is big data nosql?

994


How do I save the results of sql query in a file?

1010


Determine if oracle date is on a weekend?

1087


What is exit statement?

1057


When is the explicit cursor used ?

1085


What is union, minus and interact commands?

1361


What does select * from mean in sql?

3325


write an sql query to get third maximum salary of an employee from a table named employee_table. : Sql dba

1011


What is the difference between database trigger and stored procedure?

1128


What are different clauses used in sql?

1169


How can we debug in PL/SQL?

1171