SQL Exercises: Find the data of employees whose last name is 'Snares'
SQL Basic Select Statement: Exercise-32 with Solution
From the following table, write a SQL query to find the details of employees whose last name is 'Snares'. Return emp_idno, emp_fname, emp_lname, and emp_dept.
Sample table: emp_details
EMP_IDNO EMP_FNAME EMP_LNAME EMP_DEPT --------- --------------- --------------- ---------- 127323 Michale Robbin 57 526689 Carlos Snares 63 843795 Enric Dosio 57 328717 Jhon Snares 63 444527 Joseph Dosni 47 659831 Zanifer Emily 47 847674 Kuleswar Sitaraman 57 748681 Henrey Gabriel 47 555935 Alex Manuel 57 539569 George Mardy 27 733843 Mario Saule 63 631548 Alan Snappy 27 839139 Maria Foster 57
Sample Solution :
-- This query selects all columns from the 'emp_details' table.
SELECT *
-- Specifies the table from which to retrieve the data (in this case, 'emp_details').
FROM emp_details
-- Filters the rows to only include those where the 'emp_lname' column has the value 'Snares'.
WHERE emp_lname = 'Snares';
Output of the Query:
emp_idno emp_fname emp_lname emp_dept 526689 Carlos Snares 63 328717 Jhon Snares 63
Code Explanation:
The said statement in SQL selects all columns from the table named 'emp_details' where the emp_lname is 'Snares'. It returns all the rows that have the last name 'Snares' in the emp_lname column.
Relational Algebra Expression:
Relational Algebra Tree:
Practice Online
Query Visualization:
Duration:
Rows:
Cost:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous Pyhton Exercise: Find the last name of all employees, without duplicates.
Next Python Exercise: List the employees that work in the department 57.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/sql-exercises/sql-retrieve-exercise-32.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics