Which statement is true regarding the above queries?

Examine the structure of the TRANSACTIONS table:
Name Null Type
TRANS_ID NOT NULL NUMBER(3)
CUST_NAME VARCHAR2(30)
TRANS_DATE DATE
TRANS_AMT NUMBER(10, 2)
You want to display the transaction date and specify whether it is a weekday or weekend.
Evaluate the following two queries:

Which statement is true regarding the above queries?

Examine the structure of the TRANSACTIONS table:
Name Null Type
TRANS_ID NOT NULL NUMBER(3)
CUST_NAME VARCHAR2(30)
TRANS_DATE DATE
TRANS_AMT NUMBER(10, 2)
You want to display the transaction date and specify whether it is a weekday or weekend.
Evaluate the following two queries:

Which statement is true regarding the above queries?

A.
Both give wrong results.

B.
Both give the correct result.

C.
Only the first query gives the correct result.

D.
Only the second query gives the correct result.

Explanation:
Range Conditions Using the BETWEEN Operator
Use the BETWEEN operator to display rows based on a range of values:
SELECT last_name, salary
FROM employees
WHERE salary BETWEEN 2500 AND 3500;
Range Conditions Using the BETWEEN Operator
You can display rows based on a range of values using the BETWEEN operator. The range that you specify
contains a lower limit and an upper limit.
The SELECT statement in the slide returns rows from the EMPLOYEES table for any employee whose salary is
between $2, 500 and $3, 500.
Values that are specified with the BETWEEN operator are inclusive. However, you must specify the lower limit
first.
You can also use the BETWEEN operator on character values:
SELECT last_name
FROM employees
WHERE last_name BETWEEN ‘King’ AND ‘Smith’;



Leave a Reply 3

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


The Tuk

The Tuk

SQL> SELECT TRANS_DATE,TO_CHAR(trans_date,’DAY’),CASE
2 WHEN TRIM(TO_CHAR(trans_date,’DAY’)) IN (‘SATURDAY’,’SUNDAY’) THEN ‘weekend’
3 ELSE ‘weekday’
4 END “Day Type”
5 FROM transactions;

TRANS_DAT TO_CHAR(TRANS_DATE,’DAY’) Day Typ
——— ———————————— ——-
09-JAN-17 MONDAY weekday
13-FEB-17 MONDAY weekday
15-JUN-17 THURSDAY weekday
05-NOV-17 SUNDAY weekend
06-NOV-17 MONDAY weekday
weekday
15-JUN-17 THURSDAY weekday
07-NOV-17 TUESDAY weekday
08-NOV-17 WEDNESDAY weekday
09-NOV-17 THURSDAY weekday
10-NOV-17 FRIDAY weekday

TRANS_DAT TO_CHAR(TRANS_DATE,’DAY’) Day Typ
——— ———————————— ——-
11-NOV-17 SATURDAY weekend

12 rows selected.

SQL>

The Tuk

The Tuk

SQL> SELECT TRANS_DATE,TO_CHAR(trans_date,’DAY’), CASE
2 WHEN TO_CHAR(trans_date,’DAY’) BETWEEN ‘MONDAY’ AND ‘FRIDAY’ THEN ‘weekday’
3 ELSE ‘weekend’
4 END “Day Type” FROM transactions;

TRANS_DAT TO_CHAR(TRANS_DATE,’DAY’) Day Typ
——— ———————————— ——-
09-JAN-17 MONDAY weekend
13-FEB-17 MONDAY weekend
15-JUN-17 THURSDAY weekend
05-NOV-17 SUNDAY weekend
06-NOV-17 MONDAY weekend
weekend
15-JUN-17 THURSDAY weekend
07-NOV-17 TUESDAY weekend
08-NOV-17 WEDNESDAY weekend
09-NOV-17 THURSDAY weekend
10-NOV-17 FRIDAY weekend

TRANS_DAT TO_CHAR(TRANS_DATE,’DAY’) Day Typ
——— ———————————— ——-
11-NOV-17 SATURDAY weekend

12 rows selected.

SQL>

Hola

Hola

C. There is probably no expression as between ‘MONDAY’ AND ‘FRIDAY’