CRT Database Management & SQL 2 — Questions and Answers
Question 1: A tobacco retailer wants to find all cigar products priced between $10 and $50. Which SQL clause correctly filters this range?
- WHERE price BETWEEN 10 AND 50 (Correct answer)
- WHERE price FROM 10 TO 50
- WHERE price >= 10 OR price <= 50
- WHERE price IN (10, 50)
Correct answer: WHERE price BETWEEN 10 AND 50
The BETWEEN operator in SQL is inclusive and correctly selects values within a specified range.
Question 2: Which SQL statement is used to add a new tobacco product record to the inventory table?
- UPDATE inventory SET product = 'cigar'
- INSERT INTO inventory VALUES (...) (Correct answer)
- ADD INTO inventory VALUES (...)
- CREATE RECORD IN inventory
Correct answer: INSERT INTO inventory VALUES (...)
INSERT INTO is the correct SQL command for adding new rows to a table.
Question 3: A retail system has a 'sales' table and a 'products' table. What SQL operation combines data from both tables based on a common product_id?
- UNION
- JOIN (Correct answer)
- MERGE
- COMBINE
Correct answer: JOIN
A JOIN operation links rows from two tables based on a related column such as product_id.
Question 4: Which SQL aggregate function would a tobacco shop manager use to count the total number of transactions in a sales table?
- SUM()
- TOTAL()
- COUNT() (Correct answer)
- NUM()
Correct answer: COUNT()
COUNT() returns the number of rows matching specified criteria in a table.
Question 5: A tobacconist database has duplicate customer email entries. Which SQL keyword removes duplicate results from a SELECT query?
- UNIQUE
- DISTINCT (Correct answer)
- NODUPE
- FILTER
Correct answer: DISTINCT
SELECT DISTINCT eliminates duplicate rows from query results.
Question 6: What does a PRIMARY KEY constraint ensure in a tobacco retail inventory database?
- Each row has a unique, non-null identifier (Correct answer)
- The column stores only numeric values
- The field is automatically encrypted
- Duplicate product names are allowed
Correct answer: Each row has a unique, non-null identifier
A PRIMARY KEY constraint enforces uniqueness and non-null values for each record in a table.
Question 7: Which SQL command permanently removes a tobacco product record from the inventory table?
- REMOVE FROM inventory WHERE id=5
- DROP inventory WHERE id=5
- DELETE FROM inventory WHERE id=5 (Correct answer)
- ERASE FROM inventory WHERE id=5
Correct answer: DELETE FROM inventory WHERE id=5
DELETE FROM with a WHERE clause removes specific rows from a database table.
A tobacco retailer wants to find all cigar products priced between $10 and $50.
Which SQL clause correctly filters this range?