Skip to main content

Question: 2.

You want to display the titles of books that meet these criteria:

1. Purchased before January 21, 20012.

Price is less then $500 or greater than $900

You want to sort the results by their data of purchase, starting with the most recently boughtbook.

Which statement should you use?

A. SELECT book_title FROM books

WHERE price between 500 and 900

AND purchase_date < '21-JAN-2001'

ORDER BY purchase_date;

B. SELECT book_titleFROM books

WHERE price IN (500,900)

AND purchase_date < '21-JAN-2001'

ORDER BY purchase date ASC;
C. SELECT book_titleFROM books

WHERE price <> 900

AND purchase_date < '21-JAN-2001'

ORDER BY purchase date DESC;

D. SELECT book_titleFROM books

WHERE (price <> 900)

AND purchase_date < '21-JAN-2001'

ORDER BY purchase date DESC;


Answer: D
Explanation:

This statement provides required results.

Incorrect Answers:

A: This query will show books with price in range $500 and $900, not less then $500 or greater than $900.

B: This query will show books with prices exactly $500 or $900, not less then $500 or greaterthan $900.

C: This order will not show correct rows because of incorrect syntax in the WHERE clause.

Comments

Popular posts from this blog

Question 8: Aggregate Functions

Examine the description of the STUDENTS table: STD_ID NUMBER(4) COURSE_ID VARCHARD2(10) START_DATE DATE END_DATE DATE Which two aggregate functions are valid on the START_DATE column? (Choose two) A. SUM(start_date) B. AVG(start_date) C. COUNT(start_date) D. AVG(start_date, end_date) E. MIN(start_date) F. MAXIMUM(start_date) Answer: C & E Explanation: It is possible to apply COUNT() and MIN() functions on the column with DATE data type. Incorrect Answers A: Function SUM() cannot be used with DATE data type column. B: Function AVG() cannot be used with DATE data type column. D: Function AVG() cannot be used with DATE data type column, and function AVG() just has one parameter X, not two. It averages all X column values returned by the SELECT statement. F: There is no MAXIMUM() function in Oracle, only MAX() function exists.

18. ADDING CHECK CONSTRAINT WHILE INSERTING.

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER NOT NULL EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) SAL NUMBER MGR_ID NUMBER DEPARTMENT_ID NUMBER You want to create a SQL script file that contains an INSERT statement. When the script is run, the INSERT statement should insert a row with the specified values into the EMPLOYEES table. The INSERT statement should pass values to the table columns as specified below: EMPLOYEE_ID: Next value from the sequence EMP_ID_SEQEMP_NAME and JOB_ID: As specified by the user during run time, through substitution variables SAL: 2000 MGR_ID: No value DEPARTMENT_ID: Supplied by the user during run time throughsubstitutionvariable. The INSERT statement should fail if the user supplies a value other than20 or 50. Which INSERT statement meets the above requirements? A. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL,&did); B. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '...

Question 6: ORDER BY with NULL

You are sorting data in a table in you SELECT statement in descending order. The column you are sorting on contains NULL records, where will the NULL record appears? A.At the beginning of the list. B.At the end of the list. C.In the middle of the list. D.At the same location they are listed in the unordered table. Answer: A Explanation: When sorting a column with null values in ascending order then the oracle places the Null values at the end of the list if the sorting is in descending order the oracle places the null values at the start of the list.