Here are the 2 questions asked in HackerRank SQL Intermediate Certification Exam, these 2 will be available in one attempt. The questions asked are Invoices Per Country and Product Sales Per City.
Invoices Per Country
SELECT co.country_name, count(*), AVG(i.total_price)
FROM country co, city ci, customer cu, invoice 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))
Product Sales Per City
SELECT ci.city_name, pr.product_name, ROUND(SUM(ii.line_total_price), 2) AS tot
FROM city ci, customer cu, invoice i, invoice_item ii, product 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
I have taken HackerRank test on 3rd June 2022. Certificate can be viewed here.
You can also get HackerRank SQL Basic Certification Solutions – FREE SQL Certification