Olawale Ahmed Alamu
1 min readNov 10, 2022

--

SQL Daily Practice — Day 8

Hello, Connections, Data Analyst and BI Enthusiasts.

It is the 8th day of our SQL daily practice on SQL-PRACTICE-DOT-COM.

Follow Olawale Ahmed Alamu and #sqldailyupdates for the previous days and daily updates.

Let’s tackle the eighth EASY tag question on SQL-PRACTICE-DOT-COM.

QUESTION: Show how many patients have a birth_date with 2010 as the birth year.

PROBLEM ANALYSIS: We are to output the number (COUNT) of patients with 2010 as their year of birth.

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 COUNT(birth_date) statement to generate the number of patients with a WHERE clause of YEAR(birth_date) = 2010

SQL SCRIPT:
-- -- -- -- -- -- — 
SELECT COUNT(birth_date)
AS total_patients
FROM patients
WHERE YEAR(birth_date) = 2010 ;
-- -- -- -- -- -- —

Screenshot image of the SQL Script and output attached below:

#sql #health #databases #dataanalytics

--

--

Olawale Ahmed Alamu

CS Grad | Power BI | Microsoft Excel | Learning and Teaching SQL Daily