Number of records from LOANS table where Rate of Interest (RoI) is above 7.0.
Number of records from LOANS table where Rate of Interest (RoI) is above 7.0.
SQL Query:
``sql
SELECT COUNT(*) FROM LOANS WHERE RoI > 7.0;
``
This counts only those LOANS records whose Rate of Interest exceeds 7.0%.
Marking Scheme
- 11 mark for the complete correct query: SELECT COUNT(*) FROM LOANS WHERE RoI > 7.0;
Hint
COUNT(*) with a WHERE clause gives the number of rows satisfying a condition.
Quick Oral Answer
SELECT COUNT(*) FROM LOANS WHERE RoI > 7.0 counts how many loan records have an interest rate above 7 percent.
Analysis & Explanation
COUNT(*) is the standard way to count matching rows without needing GROUP BY when only a single overall total is required.
Concept
- WHERE RoI > 7.0 filters rows before COUNT(*) tallies them.
- COUNT(*) counts rows regardless of NULLs in any particular column, unlike COUNT(column_name).
Exam trap
- Using SELECT instead of SELECT COUNT() lists every matching row instead of returning a single numeric count, which does not answer 'number of records'.
Common Mistakes
- 1Writing WHERE RoI > 7 without matching the column's decimal data type/format precisely.
- 2Using SELECT * instead of SELECT COUNT(*), which lists all matching rows instead of returning a single count.
Interesting Facts
COUNT(*) is generally the fastest counting form in most RDBMS engines because it does not need to check individual column values for NULL.
MySQL evaluates the WHERE clause before any aggregate function is applied, which is why filtering and counting can be combined in a single simple query here.
Spotted a mistake or something unclear?
Tell us — we fix reported answers fast.
Frequently Asked Questions
What is the difference between COUNT(*) and COUNT(RoI)?
COUNT(*) counts all rows matching the WHERE condition regardless of NULL values, while COUNT(RoI) would ignore rows where RoI is NULL; for a clean numeric column like RoI, both usually give the same result.
Does the WHERE clause run before or after COUNT(*)?
Before — WHERE filters individual rows first, and only the rows that pass the condition are then counted by COUNT(*).