Which three SQL statements would execute successfully?

Here is the structure and data of the CUST_TRANS table:

Dates are stored in the default date format dd-mm-rr in the CUST_TRANS table.
Which three SQL statements would execute successfully? (Choose three.)

Here is the structure and data of the CUST_TRANS table:

Dates are stored in the default date format dd-mm-rr in the CUST_TRANS table.
Which three SQL statements would execute successfully? (Choose three.)

A.
SELECT transdate + ’10’ FROM cust_trans;

B.
SELECT * FROM cust_trans WHERE transdate = ’01-01-07′;

C.
SELECT transamt FROM cust_trans WHERE custno > ’11’;

D.
SELECT * FROM cust_trans WHERE transdate=’01-JANUARY-07′;

E.
SELECT custno + ‘A’ FROM cust_trans WHERE transamt > 2000;



Leave a Reply 18

Your email address will not be published. Required fields are marked *


lokesh

lokesh

SELECT transdate + ’10′ FROM cust_trans;
SELECT transamt FROM cust_trans WHERE custno > ’11′;
SELECT * FROM cust_trans WHERE transdate=’01-JANUARY-07′;

Alisha

Alisha

can 11 be in single quotes?

bannela219

bannela219

given that Dates are stored in the default date format dd-mm-rr in the CUST_TRANS table
then
why not B is correct?

jrmartinsbr

jrmartinsbr

“B” is correct only if the parameter NLS_DATE_FORMAT = ‘DD/MM/RRRR’.
In this case, the default date format dd-mm-rr, i.e, NLS_DATE_FORMAT = ‘DD-MON-RR’.

For test, execute ” alter session set NLS_DATE_FORMAT = ‘DD-MON-RR’ “

Justyna

Justyna

If you look at how data are displayed you can see ’01-JAN-07′. It seems that in the seesion is nls_date_format=’DD-MON-RR’ and then you get ORA-01843 – “not a valid monht”

kabelo

kabelo

I think that the question is a typo. Should be. Dates are stored in the default date format dd-MON-rr

RK

RK

Look at Question #93
Same Q but the default date format is dd-mon-rr

RK

RK

Home > Oracle Questions & Answers > 1Z0-051 > Which SQL statements would execute successfully?

NOT

Home > Oracle Questions & Answers > 1Z0-051 (v.1) > Which three SQL statements would execute successfully?

spellublind

spellublind

SQL> alter session set nls_date_format=’dd-mm-rr’;

Session altered.

SQL> select * from cust_trans where transdate=’01-01-07′;

CU TRANSDAT TRANSAMT
— ——– ———-
11 01-01-07 1000

SQL> select * from cust_trans where transdate=’01-JANUARY-07′;

CU TRANSDAT TRANSAMT
— ——– ———-
11 01-01-07 1000

Both B and D works for the above session parameter! can somebody explain why?

Gabriel K

Gabriel K

Yop, for me too. And couple of others that I tried without using TO_DATE, which I normaly use always! Looks like implicit conversion works better and better in Oracle which is cool except for some testing questions. 🙂

Siva

Siva

why the Answer E is not correct?

Josh

Josh

That’s bec you can´t add a string to a number

kellar

kellar

It will give an error as “Invalid Number”

via

via

Hurrah, that’s what I was seeking for, what a stuff! existing here at this blog, thanks admin of this web site.|

ydisconzi

ydisconzi

IF ‘NLS_DATE_FORMAT’ = DD-MM-RR CORRECT QUESTIONS -> A,B,C,D
IF ‘NLS_DATE_FORMAT’ = DD-MON-RR CORRECT QUESTIONS -> A,C,D

SQL> select value from v$nls_parameters where parameter=’NLS_DATE_FORMAT’;
VALUE
—————————————————————-
DD-MM-RR

A)
SQL> SELECT hire_date + ’10’ FROM employees;
HIRE_DAT
——–
27-09-87
27-02-96

B)
SQL> SELECT first_name,hire_date FROM employees WHERE hire_date=’03-01-90′;
FIRST_NAME HIRE_DAT
——————– ——–
Alexander 03-01-90

C)
SQL> SELECT first_name FROM employees WHERE custno > ’11’;
FIRST_NAME
——————–
eva

D)
SQL> SELECT first_name,hire_date FROM employees WHERE hire_date=’03-JAN-90′;
FIRST_NAME HIRE_DAT
——————– ——–
Alexander 03-01-90
OR
SQL> SELECT first_name,hire_date FROM employees WHERE hire_date=’03-JANEIRO-90′;
FIRST_NAME HIRE_DAT
——————– ——–
Alexander 03-01-90

SQL> select value from v$nls_parameters where parameter=’NLS_DATE_FORMAT’;
VALUE
—————————————————————-
DD-MON-RR

A)
SQL> SELECT hire_date + ’10’ FROM employees;
HIRE_DATE
———
27-SET-87
27-FEV-96

B)
SQL> SELECT first_name,hire_date FROM employees WHERE hire_date=’03-01-90′;
SELECT first_name,hire_date FROM employees WHERE hire_date=’03-01-90′
*
ERRO na linha 1:
ORA-01843: nÒo Ú um mÛs vßlido

C)
SQL> SELECT first_name FROM employees WHERE custno > ’11’;
FIRST_NAME
——————–
eva

D)
SQL> SELECT first_name,hire_date FROM employees WHERE hire_date=’03-JAN-90′;
FIRST_NAME HIRE_DATE
——————– ———
Alexander 03-JAN-90
OR
SQL> SELECT first_name,hire_date FROM employees WHERE hire_date=’03-JANEIRO-90′;