A sales manager wants to know the total revenue from the orders table, which has a column called order_amount. Which SQL function should they use? SELECT COUNT(order_amount) FROM orders SELECT SUM(order_amount) FROM orders SELECT AVG(order_amount) FROM orders SELECT MAX(order_amount) FROM orders Answer: SELECT SUM(order_amount) FROM orders Explanation: SUM adds up all the values in a column, which is what’s needed for total revenue. COUNT would only return how many orders exist, AVG would give the average order size, and MAX would only show the largest single order.
Blog
A movie rental company has a movies table with title and rel…
A movie rental company has a movies table with title and release_year. The manager wants to see the movies listed from the newest to the oldest release year. Which SQL query should they run? SELECT * FROM movies ORDER BY release_year ASC SELECT * FROM movies ORDER BY release_year DESC SELECT release_year FROM movies SELECT * FROM movies GROUP BY release_year Answer: SELECT * FROM movies ORDER BY release_year DESC Explanation: DESC sorts in descending order, so the most recent release years appear first. ASC would list from oldest to newest. Selecting only release_year shows one column without sorting all movies, and GROUP BY is not a sorting tool.
A car rental company has a rentals table with columns car_ty…
A car rental company has a rentals table with columns car_type and days_rented. The operations team wants to know the longest rental period for each car type. Which SQL query should they use? SELECT car_type, MAX(days_rented) FROM rentals GROUP BY car_type SELECT car_type, days_rented FROM rentals ORDER BY days_rented DESC SELECT MAX(days_rented) FROM rentals SELECT car_type, SUM(days_rented) FROM rentals GROUP BY car_type Answer: SELECT car_type, MAX(days_rented) FROM rentals GROUP BY car_type Explanation: MAX(days_rented) finds the longest rental per car type when grouped accordingly. Simply ordering by days_rented shows all rentals but not summaries. A plain MAX(days_rented) gives the longest rental overall, not per type. SUM(days_rented) would calculate totals, not maximums.
Why might an organization use a view instead of giving direc…
Why might an organization use a view instead of giving direct access to a full table? To permanently delete unnecessary data To automatically increase query performance To restrict access to only part of the table To replace the need for indexes Answer: To restrict access to only part of the table Explanation: Views can hide sensitive columns or rows, allowing controlled access. They don’t automatically boost performance, delete data, or replace indexes.
Which of the following is the best example of how a Large La…
Which of the following is the best example of how a Large Language Model operates?
A bank has an accounts table with (account_id, holder_name,…
A bank has an accounts table with (account_id, holder_name, balance). They want to add a new account with ID 5001, holder name Emma, and starting balance 1000.00. Which SQL is correct? INSERT accounts VALUES (5001, ‘Emma’, 1000.00); INSERT INTO accounts VALUES (5001, ‘Emma’, 1000.00); ADD INTO accounts (5001, ‘Emma’, 1000.00); UPDATE accounts (5001, ‘Emma’, 1000.00); Answer: INSERT INTO accounts VALUES (5001, ‘Emma’, 1000.00); Explanation: The correct syntax is INSERT INTO … VALUES. The others misuse SQL commands (INSERT, ADD, UPDATE).
What are the values of num through the iterations of the fol…
What are the values of num through the iterations of the following for loop? for num in range(2, 9, 2):
A patient with a breast biopsy that is positive for cancer i…
A patient with a breast biopsy that is positive for cancer is to undergo a sentinel lymph node biopsy (SLNB). The nurse explains this procedure to the patient. Which of the following statements will the nurse include in the explanation?
What will be the value of c when the following code is execu…
What will be the value of c when the following code is executed? c = 0for i in range(2): j = 0 while j
What will be the value of num after the following code is ex…
What will be the value of num after the following code is executed? num = 2i = 1while i