Skip to content

RunTime error #2

Description

@surajbanerjee

The SQL query you provided has a few syntax errors and logical issues that need to be corrected

SELECT co.country_name, COUNT(*) AS number_of_invoices, AVG(i.total_price) AS average_total_price FROM country co JOIN city ci ON co.id = ci.country_id JOIN customer cu ON ci.id = cu.city_id JOIN invoice i ON cu.id = i.customer_id GROUP BY co.country_name HAVING AVG(i.total_price) > (SELECT AVG(total_price) FROM invoice);
correction:
HAVING Clause with Subquery:
The HAVING clause now correctly uses a subquery to calculate the overall average total_price from the invoice table.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions