w3resource

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

SQL Basic Select Statement: Exercise-18 with Solution.

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


Sample Solution:

SELECT *
 FROM nobel_win 
   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.

Practice Online


Query Visualization:

Duration:

Query visualization of Show all the details of the winners with first name Louis - Duration

Rows:

Query visualization of Show all the details of the winners with first name Louis - Rows

Cost:

Query visualization of Show all the details of the winners with first name Louis - Cost

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

Previous Python Exercise: Details of the Prime Ministerial winners after 1972.
Next Python Exercise: All winners in Physics for 1970 and Economics for 1971.

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