write a query that calculates the country wise sales for all car models along with the total sales for the year 2020 in ascending order
Attachments:
Answers
Answered by
28
Answer:
select ct.name,cm.name,sl.quantity from sales as sl inner join country as ct on sl.country_id=ct.id inner join car_model as cm on cm.id=sl.model_id where sl.sales_date BETWEEN '01-01-2020' AND '12-31-2020' order by ct.name;
Explanation:
csk is the winner of 2021 ipl
Answered by
34
Answer:
SELECT c.name, m.name, SUM(m.price*s.quantity) AS total_sales
FROM sales s
INNER JOIN country c ON c.id=s.country_id
INNER JOIN car_model m ON m.id=s.model_id
WHERE STR_TO_DATE(s.sales_date, '%m/%d/%Y') BETWEEN '2020-01-01' AND '2020-12-31'
GROUP BY c.name, m.name ORDER BY c.name;
Explanation:
Similar questions