Which three SQL statements would execute successfully?

Examine the structure and data of the CUST_TRANS table:

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

Examine the structure and data of the CUST_TRANS table:

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

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;

Explanation:



Leave a Reply 12

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


Sergio

Sergio

In option C, it’s ’11’ instead of “11”, in that case, it is a valid SQL statement.

Mac/Philippines

Mac/Philippines

you got it.

Ladi

Ladi

Correct B,D,E

shape

shape

B is not correct, it throws an error: ORA-01843: not a valid month.
E isn’t correct also, error: ORA-01722: invalid number.

Correct answers are:
A,C,D.

shape

shape

Sorry, C is not correct – Sergio explain it.

Tram

Tram

I’m sorry why A is correct? What is the result of transdate + ’10’? Isn’t transdate a date type? If transdate + 10 it is correct but ’10’ it’s a character data type? Thanks in advance

KSI

KSI

Transdate in this example is the column name, see the describe table output.
That means that the ‘transdate’ will be replaced by a value stored in the table and added to 10.

A,C,D are correct.

SeanO

SeanO

I still can’t see how C can be correct. Using double quotes would raise an error.
If the statement was something else as Sergio suggests it would be correct, but then if any incorrect statement was something else, they could be correct.

Valts

Valts

Are these realy the questions that will be in the exam?

The Tuk

The Tuk

SQL> desc cust_trans;
Name Null? Type
—————————————– ——– —————————-
CUSTNO NOT NULL CHAR(2)
TRANSDATE DATE
TRANSAMT NUMBER(6,2)

SQL>
SQL> select TRANSAMT from cust_trans where CUSTNO > “11” ;
select TRANSAMT from cust_trans where CUSTNO > “11”
*
ERROR at line 1:
ORA-00904: “11”: invalid identifier

SQL>

The Tuk

The Tuk

SQL> select TRANSAMT from cust_trans where CUSTNO > 11;

TRANSAMT
———-
2000
3000

SQL>