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??

Answers were Sorted based on User's Feedback



suppose we have values like 1 5 7 in a colum.Now we want numbers like(2 3 4 6) that exists between..

Answer / 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

suppose we have values like 1 5 7 in a colum.Now we want numbers like(2 3 4 6) that exists between..

Answer / kavitha n

Create Table Missingsquence ( Num Number);

sql > select Num from Missingsquence ;

Missingsquence
--------------
1
5
7

SELECT LEVEL num
FROM DUAL
CONNECT BY LEVEL <= 7
MINUS
SELECT num
FROM missingsquence;

Is This Answer Correct ?    7 Yes 3 No

suppose we have values like 1 5 7 in a colum.Now we want numbers like(2 3 4 6) that exists between..

Answer / elumalai d

--QUESTION36:-What is different between union and minus?

UNOIN:- it returns all the records from both tables without duplicates.
Example:-
A={1,2,3,4}
B={2,3,4,5,6}
AUB={1,2,3,4,5,6}

CREATE TABLE question36 (empid NUMBER);
CREATE TABLE quest36 (empid NUMBER);

INSERT INTO question36 VALUES(1);
INSERT INTO question36 VALUES(2);
INSERT INTO question36 VALUES(3);
INSERT INTO question36 VALUES(4);

INSERT INTO quest36 VALUES(2);
INSERT INTO quest36 VALUES(3);
INSERT INTO quest36 VALUES(4);
INSERT INTO quest36 VALUES(5);
INSERT INTO quest36 VALUES(6);
COMMIT;

SELECT empid FROM question36
UNION
SELECT empid FROM quest36;

DELETE FROM question36;
DELETE FROM quest36;
COMMIT;

MINUS:- it returns table A values not available in table B.
Example:-
A={1,2,3,4}
B= {2,3,5}
A-B={1,4}

INSERT INTO question36 VALUES(1);
INSERT INTO question36 VALUES(2);
INSERT INTO question36 VALUES(3);
INSERT INTO question36 VALUES(4);

INSERT INTO quest36 VALUES(2);
INSERT INTO quest36 VALUES(3);
INSERT INTO quest36 VALUES(5);
COMMIT;

SELECT empid FROM question36
MINUS
SELECT empid FROM quest36;

DROP TABLE question36;
DROP TABLE quest36;

Is This Answer Correct ?    0 Yes 0 No

suppose we have values like 1 5 7 in a colum.Now we want numbers like(2 3 4 6) that exists between..

Answer / ajitnayak

select rownum
from dual
connect by level <= (select max(a) from mising_values)
minus
select * from mising_values;

Is This Answer Correct ?    0 Yes 0 No

suppose we have values like 1 5 7 in a colum.Now we want numbers like(2 3 4 6) that exists between..

Answer / ramya p

You could also use this query:

select * from <table_name>
where mod(column,2)=0;

Is This Answer Correct ?    1 Yes 11 No

Post New Answer

More SQL PLSQL Interview Questions

What is the difference between function and procedure in pl/sql?

0 Answers  


what is meant by nl2br()? : Sql dba

0 Answers  


What is a bitmap index?

4 Answers   Choice Solutions, Infosys,


how to drop an existing table in mysql? : Sql dba

0 Answers  


Can u create a primary key with out unique index.

8 Answers  


What is the difference between nvl function, ifnull function, and isnull function?

0 Answers  


How to select the Nth maximum salary from Table Emp in Oracle SQL Plus ?

0 Answers   MCN Solutions,


Is left join same as inner join?

0 Answers  


What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?

4 Answers  


Types of joins ?

11 Answers   Polaris, TCS,


What are the advantages of indexing?

0 Answers  


What is a sql statement?

0 Answers  


Categories