SQL Queries on Paper
سؤال انترفيو في ماكس إيه بي (مصر) · المرحلة: انترفيو تقني · المجال: SQL وقواعد البيانات · الوظيفة: مهندس باك إند · الصعوبة: متوسط · اتسأل مرتين، آخرها يوليو 2025
What they ask
The technical round is with the engineering manager, in person, and it is old school: the questions are printed on paper and you write your answers on paper, SQL included. There is no sample data and no schema handed to you, so part of the exercise is stating your assumptions out loud before you write.
The questions are in the SQL area a B2B grocery marketplace cares about, for example:
- Given
retailers(id, city),orders(id, retailer_id, created_at, status, total), andorder_items(order_id, product_id, qty, price), return the top 5 retailers by total order value in the last 30 days. - List retailers who have placed no order in the last 60 days but had at least one order before that (churn candidates).
- For each city, the retailer with the second-highest order count.
- Explain what changes if
orders.totalis not stored and must be derived fromorder_items.
They may follow with which index you would add for query 1 and why.
What they look for
- You draw the schema and name your assumptions (timezones, cancelled orders, currency) before writing.
- Correct joins and grouping written by hand, no autocomplete to lean on.
- Comfort with window functions or a clean alternative for ranking.
- Knowing the difference between
WHEREandHAVING, and betweenLEFT JOIN ... IS NULLandNOT EXISTS. - Being able to say how the query behaves on a large
orderstable.
The backend stack is Python with Django REST Framework on PostgreSQL, so Postgres-flavoured SQL is welcome.