From the following table, write a SQL query to find the details of 1970 Nobel Prize winners. Order the results by subject, ascending except for ‘Chemistry’ and ‘Economics’ which will come at the end of the result set. Return year, subject, winner, country, and category.
+——+————+——————+———+———–+
| YEAR | SUBJECT | winner | COUNTRY | CATEGORY |
+——+————+——————+———+———–+
| 1970 | Literature | Alsandr Solzsyn | Russia | Linguist |
| 1970 | Physics | Hannes Alfven | Sweden | Scientist |
| 1970 | Physics | Louis Neel | France | Scientist |
| 1970 | Physiology | Bernard Katz | Germany | Scientist |
| 1970 | Physiology | Julius Axelrod | USA | Scientist |
| 1970 | Physiology | Ulf von Euler | Sweden | Scientist |
| 1970 | Chemistry | Luis Fico Leloir | France | Scientist |
| 1970 | Economics | Paul Samuelson | USA | Economist |
+——+————+——————+———+———–+
Below is the solution for the question
select *
from nobel_win
where year = 1970
order by
case
WHEN subject IN (‘Economics’,’Chemistry’)
THEN 1 ELSE 0
END ASC,
subject,
winner;
Source: https://www.w3resource.com/sql-exercises/sql-retrieve-exercise-24.php