w3resource

SQL Exercises: Details of the Prime Ministerial winners after 1972

SQL Basic Select Statement: Exercise-17 with Solution.

Write a SQL query to display all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin.

Sample table: nobel_win

 

Sample Solution:

SELECT * FROM nobel_win
 WHERE year >1972
  AND winner IN ('Menachem Begin',
                  'Yitzhak Rabin');

Output of the Query:

year	subject	winner		country	category
1978	Peace	Menachem Begin	Israel	Prime Minister
1994	Peace	Yitzhak Rabin	Israel	Prime Minister

Code Explanation:

The above SQL query retrieves all columns from the 'nobel_win' table where the year of the award is greater than 1972 and the winner's name is either "Menachem Begin" or "Yitzhak Rabin". The query will return all rows that match these criteria, resulting in a list of all Nobel Prizes awarded after 1972 to either Menachem Begin or Yitzhak Rabin. The IN operator allows to check if a value is within a set of values, in this case the query will filter for rows where the winner column is either Menachem Begin or Yitzhak Rabin

Relational Algebra Expression:

Relational Algebra Expression: Show all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin.

Relational Algebra Tree:

Relational Algebra Tree: Show all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin.

Practice Online


Query Visualization:

Duration:

Query visualization of Show all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin - Duration

Rows:

Query visualization of Show all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin - Rows

Cost:

Query visualization of Show all details of the Prime Ministerial winners after 1972 of Menachem Begin and Yitzhak Rabin - Cost

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

Previous Python Exercise: Details of Chemistry prize winners from 1965 to 1975.
Next Python Exercise: Show all the details of the winners with the first name Louis.

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.

SQL: Tips of the Day

What is the best way to paginate results in SQL Server?

SELECT  *
FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY OrderDate ) AS RowNum, *
          FROM      Orders
          WHERE     OrderDate >= '1980-01-01'
        ) AS RowConstrainedResult
WHERE   RowNum >= 1
    AND RowNum < 20
ORDER BY RowNum

Database: SQL Server

Ref: https://bit.ly/3MGrNlk

 





We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook