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 the difference between alert log file and tarce file ?

1634


How to assign data of the deleted row to variables?

579


What is snapshot is too old? Give and example for better understand.

1100


How are extents allocated to a segment?

580


What are the types of trigger in oracle?

575






What is the exact use of Collections?

1682


What is an oracle function?

600


Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.

1674


What are the differences between number and binary_float in oracle?

571


What is the difference between formal parameters and actual parameters?

547


How to upsert (update or insert into a table)?

539


Why does oracle 9i treat an empty string as null?

539


What is an oracle recycle bin?

551


Whether any commands are used for months calculation? If so, what are they?

598


What are the attributes of the cursor?

561