Olawale Ahmed Alamu
1 min readNov 10, 2022

--

SQL Daily Practice — Day 9

SQL MAX() Function

Hello, Connections, Data Analyst, BI Analyst and SQL Enthusiasts.

Welcome to the 9th day of our daily practice on SQL-PRACTICE-DOT-COM.

Follow Olawale Ahmed Alamu and #sqldailypractice for #day1 to #day8 and subsequent days.

SQL MAX() function returns the largest value from a selected column.

QUESTION: Show the first_name, last_name, and height of the patient with the greatest height.

PROBLEM ANALYSIS: We are to output the first name, last_name and height of the tallest patient on the patients' table.

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 an SQL SELECT statement to output the first_name, last_name and MAX(height) of the tallest patient FROM the patients'table.

SQL SCRIPT:
-- -- -- -- -- -- — 
SELECT
first_name,
last_name,
MAX(height) AS maximum_height
FROM patients; 
-- -- -- -- -- -- —

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