can you fix errors for sql auction web service lot statistics: SELECT name, id FROM…
- User
can you fix errors for sql auction web service lot statistics: SELECT name, id FROM lots; SELECT MIN (amount) AS min_offer, ROUND(AVG(amount), 2) AS avg_offer, MAX (amount) AS max_offer, COUNT(amount) AS offers FROM offers ORDER BY COUNT(amount) DESC;
- Assistant
The primary issue in the SQL statements you've provided lies in the second query, which attempts to order the result set based on the count of
amountin theofferstable. TheORDER BYclause isn't used correctly because the aggregation results in a single row of output, and therefore, sorting that single row is meaningless and could cause errors depending on your SQL dialect.Here's a corrected version of your SQL queries:
-
This query is straightforward and doesn't contain errors:
sql
-