w3resource

SQL Exercises: Show all the details of the winners with the first name Louis


18. Winners with First Name Louis

From the following table, write a SQL query to retrieve the details of the winners whose first names match with the string ‘Louis’. Return year, subject, winner, country, and category.

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
.....
1994 Literature                Kenzaburo Oe                                  Japan                  Linguist

View the table

Sample Solution:

-- This query selects all columns from the 'nobel_win' table.
SELECT *
-- 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 'winner' column starts with 'Louis '.
WHERE winner LIKE 'Louis %';

Output of the Query:

year	subject	winner	country	category
1970	Physics	Louis Neel	France	Scientist

Code Explanation:

The said SQL query retrieves all columns from the 'nobel_win' table where the winner's name starts with "Louis" followed by any characters. The query will return all rows that match this criteria, resulting in a list of all Nobel Prizes awarded to winners whose name starts with "Louis". The LIKE operator is used to match a specific pattern, in this case it will match any name that starts with Louis followed by any characters. The '%' sign is a wildcard character that matches any sequence of characters.

Relational Algebra Expression:

Relational Algebra Expression: Show all the details of the winners with first name Louis.


Relational Algebra Tree:

Relational Algebra Tree: Show all the details of the winners with first name Louis.


Go to:


PREV : Prime Ministers After 1972.
NEXT : Combine Winners (Physics 1970 & Economics 1971).


Practice Online



For more Practice: Solve these Related Problems:

  • Write a SQL query to find all Nobel Prize winners whose first name starts with "John".
  • Write a SQL query to retrieve details of winners whose first name contains "Marie".
  • Write a SQL query to list all winners whose first name ends with "s".
  • Write a SQL query to display Nobel laureates whose first name matches "Robert".

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.



Follow us on Facebook and Twitter for latest update.