Skip to main content

Question: 4 - WHERE clause

The ORDERS table has these columns:


ORDER_ID NUMBER(4) NOT NULL
CUSTOMER_ID NUMBER(12) NOT NULL
ORDER_TOTAL NUMBER(10,2)


The ORDERS table tracks the Order number, the order total, and the customer to whom the Order belongs.

Which two statements retrieve orders with an inclusive total that ranges between 100.00 and 2000.00 dollars?


A.SELECT customer_id, order_id, order_total
FROM orders
RANGE ON order_total (100 AND 2000) INCLUSIVE;


B.SELECT customer_id, order_id, order_total
FROM orders
HAVING order_total BETWEEN 100 and 2000;


C. SELECT customer_id, order_id, order_total
FROM orders
WHERE order_total BETWEEN 100 and 2000;


D. SELECT customer_id, order_id, order_total
FROM orders
WHERE order_total >= 100 and <= 2000;


Answer:C


Explanation:

Answers C provides correct results to show. You can use BETWEEN or comparison operations to retrieve data.



Incorrect Answers

A: There is no RANGE ON or INCLUSIVE keyword in Oracle.
B: HAVING clause can be use only in conjunction with the GROUP BY clause.
D: Syntax 'order_total >= 100 and <= 2000' is incorrect.

Comments

Popular posts from this blog

21.Oracle - The self documenting dictionary

Oracle - The self documenting dictionary Oracle's Data dictionary is itself self documenting. we can query DICTIONARY AND DICT_COLUMNS views for descriptions of the data dictionary views and their columns. The following query gives the descriptions of all of the data dictionary views. SELECT table_name, comments FROM dictionary ORDER BY table_name; It gives the large amount of output. By using where class we can focus a smaller set of views as like the following query. SELECT table_name, comments FROM dictionary WHERE table_name LIKE '%TABLE%' ORDER BY table_name It returns all views containing the word 'TABLE' Like wise We can query the DICT_COLUMNS view also. It gives the descriptions for the columns for all views. Following query retrieves descriptions for the columns in ALL_TAB_COLUMNS. SELECT column_name, comments FROM dict_columns WHERE table_name = 'ALL_TAB_COLUMNS'; This is a sample one. We can learn lot about oracle through data d...

Question 9: null in where clause

The EMP table contains these columns: LAST NAME VARCHAR2(25) SALARY NUMBER(6,2) DEPARTMENT_ID NUMBER(6) You need to display the employees who have not been assigned to any department. You write the SELECT statement: SELECT LAST_NAME, SALARY, DEPARTMENT_ID FROM EMP WHERE DEPARTMENT_ID = NULL; What is true about this SQL statement? A. The SQL statement displays the desired results. B. The column in the WHERE clause should be changed to display the desired results. C. The operator in the WHERE clause should be changed to display the desired results. D. The WHERE clause should be changed to use an outer join to display the desired results. Answer: C Explanation: The operator in the WHERE clause should be changed to display the desired results. There are times when you want to substitute a value in place of NULL. Oracle provides this functionality with a special function, called NVL(). You can use operation equal with the keywords IS NULL, or you can achieve desired results using NVL() fu...

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, '...