Functions-Triggers ... Exercises: Problem 30. Count of Countries by Currency
Къде е уловката в тази задача, че не минава в judge? Или по-скоро къде е грешката в условието?
Условието:
Find the number of countries for each currency. Display three columns: currency code, currency description and number of countries. Sort the results by number of countries (from highest to lowest), then by currency description alphabetically. Name the columns exactly like in the table below. Submit your query statement as Prepare DB & run queries in Judge.
Ето и заявката:
SELECT c.currency_code AS CurrencyCode,
cu.description AS Currency,
COUNT(c.country_code) AS NumberOfCountries
FROM countries AS c
RIGHT JOIN currencies AS cu
ON cu.currency_code = c.currency_code
GROUP BY c.currency_code, cu.description
ORDER BY NumberOfCountries DESC, Currency ASC;
Както и да я въртя моята, не минава. Предполагам, че пак е проблем от DB енджина на judge. Oчаквам, някой от Софтуни да се произнесе по проблема, защото гледам има и други на които не минава.
Работата е, че currency_code-а трябва да се вземе от таблицата currencies
Ако това имаш в предвид:
SELECT cu.currency_code AS CurrencyCode,
cu.description AS Currency,
COUNT(cu.currency_code) AS NumberOfCountries
FROM countries AS c
LEFT JOIN currencies AS cu
ON cu.currency_code = c.currency_code
GROUP BY c.currency_code, cu.description
ORDER BY NumberOfCountries DESC, Currency ASC;
пак не минава!
ИЛИ
SELECT cu.currency_code AS CurrencyCode,
cu.description AS Currency,
COUNT(cu.currency_code) AS NumberOfCountries
FROM countries AS c
LEFT JOIN currencies AS cu
ON cu.currency_code = c.currency_code
GROUP BY cu.currency_code, cu.description
ORDER BY NumberOfCountries DESC, Currency ASC;
пак не минава!