GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

A hospital has a patients table with columns city and patien…

A hospital has a patients table with columns city and patient_id. Administrators want to list cities with more than 100 patients. Which SQL should they use? SELECT city, COUNT(patient_id) FROM patients GROUP BY city HAVING COUNT(patient_id) > 100 SELECT city, COUNT(patient_id) FROM patients WHERE COUNT(patient_id) > 100 GROUP BY city SELECT city, patient_id FROM patients GROUP BY city HAVING patient_id > 100 SELECT city, COUNT(patient_id) FROM patients GROUP BY city WHERE COUNT(patient_id) > 100 Answer: SELECT city, COUNT(patient_id) FROM patients GROUP BY city HAVING COUNT(patient_id) > 100 Explanation: Aggregates like COUNT can only be filtered using HAVING. Using WHERE COUNT(…) is invalid. Filtering on patient_id > 100 incorrectly checks row-level values instead of group totals.

Read Details

A telecom company has a calls table with columns region and…

A telecom company has a calls table with columns region and call_duration. Analysts want to find regions where the average call duration is less than 3 minutes. Which query is correct? SELECT region, AVG(call_duration) FROM calls GROUP BY region HAVING AVG(call_duration) < 3 SELECT region, AVG(call_duration) FROM calls WHERE AVG(call_duration) < 3 GROUP BY region SELECT region, call_duration FROM calls GROUP BY region HAVING call_duration < 3 SELECT region, SUM(call_duration) FROM calls GROUP BY region HAVING SUM(call_duration) < 3 Answer: SELECT region, AVG(call_duration) FROM calls GROUP BY region HAVING AVG(call_duration) < 3 Explanation: HAVING is the correct clause for filtering by an aggregate. AVG(call_duration) gives the mean per region. Using WHERE with an aggregate is invalid. Checking SUM(call_duration) < 3 is meaningless for durations, and filtering on row-level call durations is not correct.

Read Details

A bank keeps transaction data in transactions and account da…

A bank keeps transaction data in transactions and account data in accounts. They run: SELECT accounts.account_id, transactions.amount FROM accounts FULL OUTER JOIN transactions ON accounts.account_id = transactions.account_id; Which statement best describes the result? Only accounts that have transactions Only transactions linked to valid accounts All accounts and all transactions, matching where possible Accounts without balances are excluded Answer: All accounts and all transactions, matching where possible Explanation: A FULL OUTER JOIN includes everything from both sides, inserting NULLs where no match exists.

Read Details

Methods for characterization of nanocrystals includes 

Methods for characterization of nanocrystals includes 

Read Details

A retail company’s database has a products table with a colu…

A retail company’s database has a products table with a column called price. The CEO asks: What’s the highest price of any product we sell? Which SQL query answers that? SELECT SUM(price) FROM products SELECT MAX(price) FROM products SELECT AVG(price) FROM products SELECT COUNT(price) FROM products Answer: SELECT MAX(price) FROM products Explanation: MAX retrieves the largest single value from the column. SUM adds all prices together, which doesn’t make sense here. AVG provides an average, and COUNT only tells how many product prices are listed.

Read Details

You’re considering attending U of A for another year, but al…

You’re considering attending U of A for another year, but also have the option to work full-time for a year. If you work, you could earn $30,000, but attending U of A would cost $20,000 in tuition and fees. You will spend$10,000 on meals in either options. What is the opportunity cost of attending U of A in this scenario?

Read Details

An airline tracks flights in a flights table with a ticket_p…

An airline tracks flights in a flights table with a ticket_price column. An analyst is asked: How many total flights are in the system? Which query answers this? SELECT COUNT(ticket_price) FROM flights SELECT SUM(ticket_price) FROM flights SELECT MAX(ticket_price) FROM flights SELECT AVG(ticket_price) FROM flights Answer: SELECT COUNT(ticket_price) FROM flights Explanation: COUNT returns the number of rows, which corresponds to the number of flights. SUM would incorrectly add ticket prices together, MAX only returns the highest price, and AVG gives the average price.

Read Details

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).

Read Details

Why might a company add an index to frequently queried colum…

Why might a company add an index to frequently queried columns in a large table? To permanently delete unused rows To improve query performance when filtering or searching To automatically update values in those columns To prevent duplicate entries Answer: To improve query performance when filtering or searching Explanation: Indexes make lookups faster. They don’t delete rows, enforce uniqueness by default, or update column values.

Read Details

In the overall training of an LLM, how is “fine-tuning” dist…

In the overall training of an LLM, how is “fine-tuning” distinguished from the initial training phase?

Read Details

Posts pagination

Newer posts 1 … 31,218 31,219 31,220 31,221 31,222 … 96,146 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top