HackerRank SQL Intermediate Certification Solution

In this blog post, you will find the HackerRank SQL Intermediate certification Solutions. This test was conducted on 15 September, 2023 and the questions are according to this date. The answers to questions are:-

Hackerrank sql intermediate certification

HackerRank SQL Intermediate Certification Solution :-

Q1 :- Invoices-Per-Country

SELECT co.country_name, count(*), AVG(i.total_price)
FROM country as co, city as ci, customer as cu, invoice as i
WHERE co.id = ci.country_id AND ci.id = cu.city_id AND cu.id = i.customer_id
GROUP BY co.country name
HAVING AVG(i.total_price) > (SELECT AVG(total price))

Q2 :- Product-Sales-Per-City

SELECT ci.city_name, pr.product_name, ROUND(SUM(ii.line_total_price), 2) as tot
FROM city as ci, customer as cu, invoice as i, invoice_item as ii, product as pr
WHERE ci.id = cu.city_id AND cu.id = i.customer_id AND i.id = ii.invoice_id AND ii.product_id = pr.id
GROUP BY ci.city_name, pr.product_name
ORDER BY tot DESC, ci.city_name, pr.product_name

Hope this blog post was helpful to you and you have got the answer to your question. Thank you for visiting our blog. If you have any doubts about any coding questions then let us know in the comments section we will answer them as soon as possible. Till then check out our more blog posts.

Leave a Comment

Your email address will not be published. Required fields are marked *