Signup not nigeria
Tue Apr 22 2025 03:42:50 GMT+0000 (Coordinated Universal Time)
Saved by
@IfedayoAwe
SELECT COUNT(DISTINCT u.id) AS student_signups
FROM user u
LEFT JOIN user_profile up ON u.id = up.user_id
LEFT JOIN parents p ON p.student_id = u.id
LEFT JOIN user parent_user ON parent_user.id = p.parent_id
LEFT JOIN user_profile parent_profile ON parent_profile.user_id = p.parent_id
WHERE u.type = 'student'
AND u.created_at BETWEEN 1740783600 AND 1743375600
AND (
-- student phone is not Nigerian
NOT (
u.phone LIKE '234%' OR
u.phone LIKE '080%' OR
u.phone LIKE '081%' OR
u.phone LIKE '070%' OR
u.phone LIKE '090%' OR
u.phone LIKE '091%'
)
OR
-- parent phone is not Nigerian
NOT (
parent_user.phone LIKE '234%' OR
parent_user.phone LIKE '080%' OR
parent_user.phone LIKE '081%' OR
parent_user.phone LIKE '070%' OR
parent_user.phone LIKE '090%' OR
parent_user.phone LIKE '091%'
)
);
content_copyCOPY
Comments