Tech for good

[Stratascratch/SQL] Find the total number of approved friendship requests in January and February 본문

IT/Data Science

[Stratascratch/SQL] Find the total number of approved friendship requests in January and February

Diana Kang 2025. 2. 26. 12:21

# Solution 1
SELECT COUNT(*) AS n_approved
FROM facebook_friendship_requests
WHERE MONTH(date_approved) IN(1,2);
# Solution 2
SELECT COUNT(*) AS n_approved
FROM facebook_friendship_requests
WHERE date_approved IS NOT NULL
AND DATE_FORMAT(date_approved, '%Y-%m') IN ('2019-01', '2019-02');