Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Managers with three or more reports

    Managers with three or more reports

    Mediumsqlself joingroup byhaving

    In staff, manager_id is the direct manager's id (or NULL). Return the name of every manager with three or more direct reports, sorted by name.

    Tables

    • staff (id INTEGER, name TEXT, manager_id INTEGER)

    Example 1

    staff

    idnamemanager_id
    1MonaNULL
    2Omar1
    3Laila1
    4Hana1
    5Ziad2
    6Ali2

    Expected result

    name
    Mona

    Constraints

    • 0 ≤ rows ≤ 1000
    • The order of rows matters

    Submit checks your solution against 7 tests, including hidden ones.

    SQL
    -- Write one SELECT query. Tables: staff
    SELECT
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.