Hi all,
Can any one give answer for this question.
Suppose im having employee table with fields, eno, ename,
dept, address1, address2, address3.
In address field employee can fill only address1 or address2
or address3... at a time he can fill three address fields.
now i want all employee names who filled only one address
field.. Plz its urjent can any one give querry.. Thanks in
advance.

Answer Posted / nathan

WITH temp AS
(SELECT 1 ID, 'delhi' add1, 'mumbai' add2, 'guj' add3
FROM DUAL
UNION ALL
SELECT 2 ID, NULL add1, 'mumbai' add2, NULL add3
FROM DUAL
UNION ALL
SELECT 3 ID, 'delhi' add1, NULL add2, 'guj' add3
FROM DUAL)
SELECT *
FROM (SELECT ID, NVL (add1, 0) + NVL (add2, 0) + NVL
(add3, 0) address
FROM (SELECT ID, DECODE (add1, NULL, NULL, 1) add1,
DECODE (add2, NULL, NULL, 1) add2,
DECODE (add3, NULL, NULL, 1) add3
FROM temp))
WHERE address = 1;

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between truncate and delete?

551


How to rename an index?

579


What is bulk copy or bcp in oracle?

600


Explain index?

733


How to create a stored procedure in oracle?

568






How do I find my oracle client driver version?

521


does the query needs a hint to access a materialized view?

1457


How to run the anonymous block again?

591


How do I find the database name in oracle?

597


Explain mutating triggers.

563


Explain the use of ignore option in imp command.

565


How to rename an existing table?

605


what is IDE,DMV in sql server?

2236


Explain a synonym?

592


When do you get a .pll extension in oracle?

671