Quiz
SQL Fundamentals
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (15)
1View the Exhibit and examine the structure of the customers table.
Using the customers table, you need to generate a report that shows an increase in the credit limit by 15% for all customers. Customers whose credit limit has not been entered should have the message "Not Available" displayed.
Which SQL statement would produce the required result?
- ASELECT NVL(cust_credit_limit, 'Not Available')*0.15 "NEW CREDIT"
FROM customers; - BSELECT NVL(cust_credit_limit*0.15, 'Not Available') "NEW CREDIT"
FROM customers; - CSELECT TO_CHAR(NVL(cust_credit_limit*0.15, 'Not Available')) "NEW CREDIT"
FROM customers; - DSELECT NVL(TO_CHAR(cust_credit_limit*0.15), 'Not Available')) "NEW CREDIT"
FROM customers;
- ASELECT NVL(cust_credit_limit, 'Not Available')*0.15 "NEW CREDIT"
2View the Exhibit and examine the structure of the promotions table.
Evaluate the following SQL statement:
SQL>SELECT promo_name,
CASE WHEN promo_cost >= (SELECT AVG(promo_cost) FROM promotions WHERE promo_category='TV')
THEN 'HIGH'
ELSE 'LOW'
END COST_REMARK
FROM promotions;
Which statement is true regarding the outcome of the above query?
- AIt shows COST_REMARK for all the promos in the table.
- BIt produces an error because the SUBQUERY gives an error.
- CIt shows COST_REMARK for all the promos in the promo category 'TV'.
- DIt produces an error because SUBQUERIES cannot be used with the case expression.
3View the Exhibit and examine the structure of the customers table.
NEW_CUSTOMERS is a new table with the columns CUST_ID, CUST_NAME and CUST_CITY that have the same data types and size as the corresponding columns in the customers table.
Evaluate the following insert statement:
INSERT INTO new_customers(cust_id, cust_name, cust_city)
VALUES(SELECT cust_id, cust_first_name || ' ' || cust_last_name, cust_city
FROM customers
WHERE cust_id > 23004);
The insert statement fails when executed.
What could be the reason?
- AThe values clause cannot be used in an INSERT with a subquery.
- BColumn names in the NEW_CUSTOMERS and CUSTOMERS tables do not match.
- CThe where clause cannot be used in a subquery embedded in an INSERT statement.
- DThe total number of columns in the NEW_CUSTOMERS table does not match the total number of columns in the CUSTOMERS table.
4Evaluate the following query:
SQL> SELECT TRUNC(ROUND(156.00, -1), -1)
FROM DUAL;
What would be the outcome?- A16
- B100
- C160
- D200
- E150
5Which two statements are true regarding single row functions?
- AMOD: returns the quotient of a division
- BTRUNC: can be used with number and date values
- CCONCAT: can be used to combine any number of values
- DSYSDATE: returns the database server current date and time
- EINSTR: can be used to find only the first occurrence of a character in a string
- FTRIM: can be used to remove all the occurrences of a character from a string
6Evaluate the following SQL statement:
SQL> SELECT promo_id, promo_category
FROM promotions
where promo_category = 'Internet' ORDER BY 2 DESC
UNION
SELECT promo_id, promo_category
FROM promotions
where promo_category = 'TV'
UNION
SELECT promo_id, promo_category
FROM promotions
where promo_category = 'Radio';
Which statement is true regarding the outcome of the above query?- AIt executes successfully and displays rows in the descending order of PROMO_CATEGORY
- BIt produces an error because positional notation cannot be used in the order by clause with set operators
- CIt executes successfully but ignores the order by clause because it is not located at the end of the compound statement
- DIt produces an error because the order by clause should appear only at the end of a compound query-that is, with the last select statement
7View the Exhibit and examine the structure of the SALES table.
The following query is written to retrieve all those product IDs from the SALES table that have more than 55000 sold and have been ordered more than 10 times.
SQL> SELECT prod_id
FROM sales
WHERE quantity_sold > 55000 AND COUNT(*)>20
GROUP BY prod_id
HAVING COUNT(*) > 10;
- AIt executes successfully and generates the required result.
- BIt produces an error because count(*) should be specified in the SELECT clause also.
- CIt produces an error because count{*) should be only in the HAVING clause and not in the WHERE clause.
- DIt executes successfully but produces no result because COUNT (prod_id) should be used instead of COUNT (*).
8Which two statements are true regarding subqueries?
- AA subquery can retrieve zero or more rows.
- BOnly two subqueries can be placed at one level.
- CA subquery can be used only in SQL query statements.
- DA subquery can appear on either side of a comparison operator.
- EThere is no limit on the number of subquery levels in the WHERE clause of a SELECT statement.
9View the Exhibit and examine the structure of the CUSTOMERS table.
You have been asked to produce a report on the customers table showing the customers details sorted in descending order of the city and in the descending order of their income level in each city.
Which query would accomplish this task?
- ASELECT cust_city, cust_income_level, cust_last_name
FROM customers
ORDER BY cust_city desc, cust_income_level DESC; - BSELECT cust_city, cust_income_level, cust_last_name
FROM customers
ORDER BY cust_income_level desc, cust_city DESC; - CSELECT cust_city, cust_income_level, cust_last_name
FROM customers
ORDER BY (cust_city, cust_income_level) DESC; - DSELECT cust_city, cust_income_level, cust_last_name
FROM customers
ORDER BY cust_city, cust_income_level DESC;
- ASELECT cust_city, cust_income_level, cust_last_name
10View the Exhibit and examine the data in the products table.
You need to display product names from the products table that belong to the 'software/other' category with minimum prices as either 2000 or 4000 and no unit
of measure.
You issue the following query:
SQL> SELECT prod_name, prod_category, prod_min_price
FROM products
WHERE prod_category like '%Other%'
AND (prod_min_price=2000 OR prod_min_price=4000)
AND prod_unit_of_measure <> '';
Which statement is true regarding the above query?
- AIt executes successfully but returns no result.
- BIt executes successfully and returns the required result.
- CIt generates an error because the condition specified for PROD_UNIT_OF_MEASURE is not valid.
- DIt generates an error because the condition specified for the prod category column is not valid.
11You need to display the first names of all customers from the customers table that contain the character 'e' and have the character 'a' in the second last position.
Which query would give the required output?
- ASELECT cust_first_name
FROM customers
WHERE INSTR(cust_first_name, 'e')<>0
AND SUBSTR(cust_firs_name, -2, 1)='a'; - BSELECT cust_first_name
FROM customers
WHERE INSTR(cust_first_name, 'e')<>''
AND SUBSTR(cust_firs_name, -2, 1)='a'; - CSELECT cust_first_name
FROM customers
WHERE INSTR(cust_first_name, 'e') is not null
AND SUBSTR(cust_firs_name, 1, -2)='a'; - DSELECT cust_first_name
FROM customers
WHERE INSTR(cust_first_name, 'e')<>0
AND SUBSTR(cust_firs_name, length(cust_first_name), -2)='a';
- ASELECT cust_first_name
12Which two statements are true regarding constraints?
- AA table can have only one primary key and one foreign key.
- BA table can have only one primary key but multiple foreign keys.
- COnly the primary key can be defined at the column and table levels.
- DThe foreign key and parent table primary key must have the same name.
- EBoth primary key and foreign key constraints can be defined at both column and table levels.
13In which three situations does a transaction complete?
- AWhen a DELETE statement is executed
- BWhen a ROLLBACK command is executed
- CWhen a PL/SQL anonymous block is executed
- DWhen a data definition language (DDL) statement is executed
- EWhen a TRUNCATE statement is executed after the pending transaction
14You issued the following command:
SQL> DROP TABLE employees;
Which three statements are true?- AAll uncommitted transactions are committed.
- BAll indexes and constraints defined on the table being dropped are also dropped.
- CSequences used in the employees table become invalid.
- DThe space used by the employees table is reclaimed immediately.
- EThe employees table can be recovered using the rollback command.
- FThe employees table is moved to the recycle bin.
15Which statement is true regarding the UNION operator?
- ABy default, the output is not sorted.
- BNull values are not ignored during duplicate checking.
- CNames of all columns must be identical across all select statements.
- DThe number of columns selected in all select statements need not be the same.
Information
- Description
- Informática Quiz on SQL Fundamentals, created by Erick Navarro on 06/11/2017.
- Author
- Erick Navarro
- Language
- English
- Views
- 4
- Tags
- Rating
- No ratings yet Rate this quiz