SQL Daily Practice — Day 3
Hello, Connections, Data Analyst and BI Enthusiasts.
It's day 3 of our SQL daily practice on SQL-practice-dot-com
Follow Olawale Ahmed Alamu for the previous days and daily updates.
Today's question is the third question on SQL-PRACTICE-DOT-COM. Let's go!
QUESTION: Show first name of patients that start with the letter 'C'.
PROBLEM ANALYSIS: We are to output the first name of patients whose first name starts with the letter 'C' i.e. names like Claudia, Caesar etc.
The patients' table has the following columns:
patient_id INT
first_name TEXT
last_name TEXT
gender CHAR(1)
birth_date DATE
city TEXT
province_id CHAR(2)
allergies TEXT
height INT
weight INT
SOLUTION: We write a SELECT statement to generate first names of patients with a WHERE clause to restrict the selection to first names starting with the letter 'C'. In this case, we use the wild card 'C%' with the LIKE keyword.
SQL SCRIPT:
-- -- -- -- -- --
SELECT first_name
FROM patients
WHERE first_name LIKE 'C%’;
-- -- -- -- -- --
Link for SQL-practice-dot-com in the comments section.
#sql #databases #dataanalytics