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
How to define an anonymous procedure without variables?
What do you know about normalization? Explain in detail?
What is a trace file and how is it created in oracle?
What is control file used for?
How can we delete duplicate rows in a table?
What is data block in Oracle?
What types of joins are used in writing subqueries?
If youre unsure in which script a sys or system-owned object is created, but you know its in a script from a specific directory, what UNIX command from that directory structure can you run to find your answer?
What is the difference between count (*), count (expression), count (distinct expression)?
What to do if dba lost the system password?
How to drop an index in oracle?
How to initialize variables with default values?
Can we use oracle pl/sql block in core java? if so how? pls get back to me .....
If any one has information regarding interview of NIC (National Informatics Centre),it would be of great help...
material view and view disadvantages?