w3resource

SQL Exercises: Display the Nobel prizes for 1970

SQL Basic Select Statement: Exercise-12 with Solution.

From the following table, write a SQL query to find the Nobel Prize winner(s) for the year 1970. Return year, subject and winner.

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
1971 Chemistry                 Gerhard Herzberg                              Germany                Scientist
1971 Peace                     Willy Brandt                                  Germany                Chancellor
1971 Literature                Pablo Neruda                                  Chile                  Linguist
1971 Economics                 Simon Kuznets                                 Russia                 Economist
1978 Peace                     Anwar al-Sadat                                Egypt                  President
1978 Peace                     Menachem Begin                                Israel                 Prime Minister
1987 Chemistry                 Donald J. Cram                                USA                    Scientist
1987 Chemistry                 Jean-Marie Lehn                               France                 Scientist
1987 Physiology                Susumu Tonegawa                               Japan                  Scientist
1994 Economics                 Reinhard Selten                               Germany                Economist
1994 Peace                     Yitzhak Rabin                                 Israel                 Prime Minister
1987 Physics                   Johannes Georg Bednorz                        Germany                Scientist
1987 Literature                Joseph Brodsky                                Russia                 Linguist
1987 Economics                 Robert Solow                                  USA                    Economist
1994 Literature                Kenzaburo Oe                                  Japan                  Linguist

Sample Solution :

-- This query selects specific columns 'year', 'subject', and 'winner' from the 'nobel_win' table.
SELECT year, subject, winner
-- 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 'year' column has the value 1970.
WHERE year = 1970;

Output of the Query:

year	subject		winner
1970	Physics		Hannes Alfven
1970	Physics		Louis Neel
1970	Chemistry	Luis Federico Leloir
1970	Physiology	Julius Axelrod
1970	Physiology	Ulf von Euler
1970	Physiology	Bernard Katz
1970	Literature	Aleksandr Solzhenitsyn
1970	Economics	Paul Samuelson

Code Explanation:

The above query in SQL that selects the "year", "subject" and "winner" columns from the 'nobel_win' table where the value of "year" column is 1970. The WHERE clause is used to filter the rows and only return the rows that match the condition specified in the WHERE clause.

Relational Algebra Expression:

Relational Algebra Expression: Select all columns against a specified condition

Relational Algebra Tree:

Relational Algebra Tree: Select all columns against a specified condition

Practice Online


Query Visualization:

Duration:

Query visualization of Display the Nobel prizes for 1970 - Duration

Rows:

Query visualization of Display the Nobel prizes for 1970 - Rows

Cost:

Query visualization of Display the Nobel prizes for 1970 - Cost

 

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous SQL Exercise: Order which will be delivered by a specified salesman.
Next SQL Exercise: Who won the 1971 Nobel Prize for Literature?.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.