https://www.youtube.com/watch?v=U8Cc9GPd51w
Similar to: - Capitalize
-- Create the Logins table
CREATE TABLE Logins (
user_id INT,
time_stamp DATETIME
);
-- Insert data into the Logins table
INSERT INTO Logins (user_id, time_stamp)
VALUES
(6, '2020-06-30 15:06:07'),
(6, '2021-04-21 14:06:06'),
(6, '2019-03-07 00:18:15'),
(8, '2020-02-01 05:10:53'),
(8, '2020-12-30 00:46:50'),
(2, '2020-01-16 02:49:50'),
(2, '2019-08-25 07:59:08'),
(14, '2019-07-14 09:00:00'),
(14, '2021-01-06 11:59:59');
-- Create the Users table
CREATE TABLE Users (
user_id INT PRIMARY KEY,
name NVARCHAR(50)
);
-- Insert values into the Users table
INSERT INTO Users (user_id, name)
VALUES
(1, 'aLice'),
(2, 'bOB');

-- Q1) Find latest login in the year 2020.
select user_id
,MAX(time_stamp) AS latest_login
from logins
where year(time_stamp) = '2020'
group by user_id

-- Q2) Capitalize
select
user_id,
CONCAT(upper(left(name,1)),LOWER(substring(name,2,length(name)))) As fixed_name
from users
order by user_id