Question:
What will be the output of the following query? SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );
Answer:
NO. Explanation : The query checks whether a given string is a numerical digit. Source: CoolInterview.com
I have query regarding this. I guess the Translate part will give the result as 1111111111, and its a numerical digit.So answer should be Yes. plz correct me , if I am wrong. Source: CoolInterview.com
Answered by: Jits | Date: 1/26/2010
| Contact Jits
actually the question is not perfect and the i think translate function is not perfectly used and also from where it will get the output atlest in question from dual will be there if from dual will add to the question the answer will be the "no" Source: CoolInterview.com
Answered by: jagan | Date: 3/14/2010
| Contact jagan
Error - From keyword not found when expected Source: CoolInterview.com
Answered by: Sekar | Date: 3/25/2010
| Contact Sekar
SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' ); Translate 1st String dont have any numeric so how will replace with 1 so i think so its answer is 0. Source: CoolInterview.com
Answered by: Atul | Date: 3/27/2010
| Contact Atul
To Jit Output of translate Query is 'A' So that whole Query Gives Output 'NO' Source: CoolInterview.com
Answered by: Anamika | Date: 3/30/2010
| Contact Anamika
Translate function first sees whether there is any numeric as there is no numeric it would return nothing so when the decode function gets the result of translate function it just search for '1' from the result as the result is nothing It would return 'No' only.So the answer is 'No' Source: CoolInterview.com
Answered by: Padmanaban | Date: 4/12/2010
| Contact Padmanaban
Hi,
This translate part will give an output A since in the string A there are no 1234567890 so the replacement with 1s is not possible..so by default it will give A and then
The rest part is DECODE('A','1','YES','NO');
That means search 1 in the expression A, but since 1 is not there in expression A so the result will be NO.
Hence the answer of the decode function is No..
I f u have any better answer then plz let me know. Source: CoolInterview.com
Answered by: Ankesh | Date: 4/20/2010
| Contact Ankesh
"No" Source: CoolInterview.com
Answered by: Ravivarma | Date: 4/21/2010
| Contact Ravivarma
it return 'NO' Source: CoolInterview.com
Answered by: shalaj verma | Date: 5/1/2010
| Contact shalaj verma
The Translate part the answer is 'A'. DECODE(A,'1','YES','NO')HERE CHECKING A=1,But not A=1 so the Answer Is ele part 'No' Source: CoolInterview.com
Answered by: senthilkumar | Date: 5/7/2010
| Contact senthilkumar
SELECT DECODE(TRANSLATE('A','1234567890',' 1111111111'), '1','YES', 'NO' ) FROM DUAL;
TRANSLATE('A','1234567890','1111111111') gives the value as the same string 'A'. because the string is only A. there is no numbers like 1234567890 exist in the string. So no translation is done.
now the query is like DECODE('A','1','YES','NO') IF THE FIRST VALUE i.e A is matches with 1 then it returns YES else it returns NO. here A!=1 so ans is NO. SUPPOSE IF THE QUERY IS LIKE THIS: select DECODE(TRANSLATE('A','1234567890','1111111111'), 'A','YES', 'NO' ) FROM DUAL; ANS:YES
Source: CoolInterview.com
Answered by: madhavi | Date: 5/25/2010
| Contact madhavi
Answer will be NO translate('A','1234567890','1111111111') will return 'A' and so decode wil return 'NO' Source: CoolInterview.com
Answered by: ruchi agarwal | Date: 5/30/2010
| Contact ruchi agarwal
NO. Source: CoolInterview.com
Answered by: venkatesh | Date: 8/12/2010
| Contact venkatesh
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|