Select the characteristics of our numeration system.
Blog
A hospital has a patients table. The administrator wants to…
A hospital has a patients table. The administrator wants to view patients sorted by last name alphabetically. Which SQL statement works best? SELECT * FROM patients ORDER BY last_name SELECT * FROM patients GROUP BY last_name SELECT * FROM patients WHERE last_name ASC SELECT * FROM patients ORDER BY last_name DESC Answer: SELECT * FROM patients ORDER BY last_name Explanation: By default, ORDER BY sorts text in ascending order (A to Z). GROUP BY would group records, not sort them. Adding WHERE last_name ASC is invalid syntax. Using DESC would sort in reverse order (Z to A).
Which statement is true about inserting rows into a table?…
Which statement is true about inserting rows into a table? You must always list every column name You can insert into multiple rows at once using commas in the VALUES list You cannot insert into text columns with INSERT INTO Insert statements automatically delete existing rows Answer: You can insert into multiple rows at once using commas in the VALUES list Explanation: SQL allows multiple records in one INSERT by separating each value set with commas. Listing columns is optional if filling all columns, and INSERT does not delete rows or restrict text fields.
When did the latest boom in AI actually begin?
When did the latest boom in AI actually begin?
A library has a books table with (book_id, title, author). W…
A library has a books table with (book_id, title, author). Which SQL correctly inserts two books at once? INSERT INTO books VALUES (1, ‘1984’, ‘Orwell’), (2, ‘Dune’, ‘Herbert’); INSERT INTO books (1, ‘1984’, ‘Orwell’) AND (2, ‘Dune’, ‘Herbert’); ADD INTO books VALUES (1, ‘1984’, ‘Orwell’), (2, ‘Dune’, ‘Herbert’); INSERT books (book_id, title, author) = (1, ‘1984’, ‘Orwell’), (2, ‘Dune’, ‘Herbert’); Answer: INSERT INTO books VALUES (1, ‘1984’, ‘Orwell’), (2, ‘Dune’, ‘Herbert’); Explanation: Multiple rows can be inserted in one INSERT by separating tuples with commas. The other options use invalid SQL syntax.
A hospital wants to create a patients table with columns:…
A hospital wants to create a patients table with columns: patient_id (unique number, required) full_name (up to 255 characters, required) age (whole number) Which SQL is correct? CREATE TABLE patients (patient_id INT NOT NULL, full_name VARCHAR(255) NOT NULL, age DECIMAL(10,2)); CREATE TABLE patients (patient_id INT NOT NULL, full_name VARCHAR(255) NOT NULL, age INT); CREATE patients TABLE (patient_id INT NOT NULL, full_name TEXT, age INT); CREATE TABLE patients (patient_id VARCHAR(255), full_name INT, age INT); Answer: CREATE TABLE patients (patient_id INT NOT NULL, full_name VARCHAR(255) NOT NULL, age INT); Explanation: INT works for identifiers and ages, VARCHAR(255) is appropriate for names, and NOT NULL ensures mandatory fields. The other options either misuse data types or have invalid syntax.
A retail company has a customers table with columns (custome…
A retail company has a customers table with columns (customer_id, name, country). They want to add a new customer named Sofia from Spain with customer_id = 101. Which SQL is correct? INSERT INTO customers VALUES (101, ‘Sofia’, ‘Spain’); INSERT customers (101, ‘Sofia’, ‘Spain’); ADD INTO customers VALUES (101, ‘Sofia’, ‘Spain’); UPDATE customers SET (101, ‘Sofia’, ‘Spain’); Answer: INSERT INTO customers VALUES (101, ‘Sofia’, ‘Spain’); Explanation: INSERT INTO … VALUES is the correct syntax. The other options misuse SQL keywords (INSERT, ADD, or UPDATE).
A sales manager wants to know the total revenue from the ord…
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.
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.