SQL Exercises: Details of Chemistry prize winners from 1965 to 1975
16. Chemistry Winners (1965-1975)
From the following table, write a SQL query to find the Nobel Prize winners in ‘Chemistry’ between the years 1965 and 1975. Begin and end values are included. Return year, subject, winner, and country.
Sample table: nobel_win
YEAR SUBJECT WINNER COUNTRY CATEGORY ---- ------------------------- --------------------------------------------- ------------------------- ------------ 1970 Physics Hannes Alfven Sweden Scientist 1970 Physics Louis Neel France Scientist 1970 Chemistry Luis Federico Leloir France Scientist 1970 Physiology Ulf von Euler Sweden Scientist 1970 Physiology Bernard Katz Germany Scientist 1970 Literature Aleksandr Solzhenitsyn Russia Linguist 1970 Economics Paul Samuelson USA Economist 1970 Physiology Julius Axelrod USA Scientist 1971 Physics Dennis Gabor Hungary Scientist ..... 1994 Literature Kenzaburo Oe Japan Linguist
Sample Solution:
-- This query selects the 'year', 'subject', 'winner', and 'country' columns from the 'nobel_win' table.
SELECT year, subject, winner, country
-- Specifies the table from which to retrieve the data (in this case, 'nobel_win').
FROM nobel_win
-- Filters the rows to only include those where the 'subject' column has the value 'Chemistry'
-- and the 'year' column has a value between 1965 and 1975 (inclusive).
WHERE subject = 'Chemistry'
AND year >= 1965 AND year <= 1975;
Output of the Query:
year subject winner country 1970 Chemistry Luis Federico Leloir France 1971 Chemistry Gerhard Herzberg Germany
Code Explanation:
The given query in SQL retrieves data from a table called 'nobel_win'. The query selects the year, subject, winner, and country columns from the table and filters the results by only displaying rows where the subject column is equal to 'Chemistry', and the year of the award is greater than or equal to 1965 and less than or equal to 1975.
The query is asking the database to select the year, subject, winner, and country of the nobel prize win for the subject named 'Chemistry' which were awarded between 1965 and 1975.
Relational Algebra Expression:
Relational Algebra Tree:
Go to:
PREV : Physics Winners Since 1950.
NEXT : Prime Ministers After 1972.
Practice Online
For more Practice: Solve these Related Problems:
- Write a SQL query to find Nobel Prize winners in "Physics" between 1965 and 1975.
- Write a SQL query to retrieve Nobel Prize winners in "Medicine" between 1965 and 1975.
- Write a SQL query to list Nobel Prize winners in "Literature" between 1965 and 1975.
- Write a SQL query to identify Nobel Prize winners in "Peace" between 1965 and 1975.
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
