Skip to content

RunTime error #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
surajbanerjee opened this issue Aug 31, 2024 · 0 comments
Open

RunTime error #2

surajbanerjee opened this issue Aug 31, 2024 · 0 comments
Assignees

Comments

@surajbanerjee
Copy link

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.

@adminazhar adminazhar self-assigned this Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants