w3resource
SQL exercises

SQL: Show the winners of a 'Physiology' prize in an early year before 1971 together with winners of a 'Peace' prize in a later year on and after the 1974

SQL Basic Select Statement : Exercise-21 with Solution.

Write a SQL query to show the winners of a 'Physiology' prize in an early year before 1971 together with winners of a 'Peace' prize in a later year on and after the 1974.

Sample table : nobel_win


Sample Solution:

SELECT *
 FROM nobel_win 
   WHERE (subject ='Physiology' AND year<1971)
UNION
SELECT *
 FROM nobel_win 
     WHERE (subject ='Peace' AND year>=1974);

Output:

SQL exercises

Query Visualization:

Duration:

Query visualization of Show the winners of a 'Physiology' prize in an early year before 1971 together with winners of a 'Peace' prize in a later year on and after the 1974 - Duration

Rows:

Query visualization of Show the winners of a 'Physiology' prize in an early year before 1971 together with winners of a 'Peace' prize in a later year on and after the 1974 - Rows

Cost:

Query visualization of Show the winners of a 'Physiology' prize in an early year before 1971 together with winners of a 'Peace' prize in a later year on and after the 1974 - Cost

Practice Online


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

Previous: Write a SQL query to show all the winners of nobel prize in the year 1970 except the subject Physiology and Economics.
Next: Write a SQL query to find all details of the prize won by Johannes Georg Bednorz.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming