{
  "app": {
    "name": "Mokabla",
    "url": "https://www.mokabla.com",
    "description": "Real interview questions from companies in Egypt, organised by company. Access is sold per company for 30 days."
  },
  "page": {
    "kind": "question",
    "title": "Question · overdue-invoices-query",
    "humanPath": "/en/c/ibm/overdue-invoices-query",
    "humanOnly": false
  },
  "identity": {
    "class": "declared",
    "agent": "ClaudeBot",
    "operator": "Anthropic",
    "verified": false,
    "reason": "The user agent is ClaudeBot (Anthropic), which identifies itself as an AI agent.",
    "signals": [
      "Known agent user agent"
    ],
    "claimable": false
  },
  "state": {
    "question": {
      "slug": "overdue-invoices-query",
      "title": "Overdue Invoices Query",
      "difficulty": "easy",
      "tags": [
        "sql",
        "technical",
        "backend",
        "data-eng"
      ],
      "is_free": true,
      "locked": false,
      "frequency": 0.75,
      "last_reported_at": "2026-05-18T14:54:21.656558Z",
      "url": "https://www.mokabla.com/en/c/ibm/overdue-invoices-query",
      "agent": {
        "page": "https://www.mokabla.com/agent/en/c/ibm/overdue-invoices-query",
        "question": "https://www.mokabla.com/agent/_call/get_question?company=ibm&question=overdue-invoices-query"
      },
      "company": {
        "slug": "ibm",
        "name_en": "IBM Egypt"
      },
      "body_md": "## Problem\nYou have two tables from a billing system:\n\n- `customers(id, name, country)`\n- `invoices(id, customer_id, amount, due_date, paid_at)`, `paid_at` is NULL while unpaid\n\nWrite a query that, as of `2026-01-31`, returns each customer who has **at least two** overdue invoices, together with the count of overdue invoices and their total amount. An invoice is overdue when it is unpaid and its due date is before the reference date. Order by total amount descending, then customer name.\n\n## Examples\n**Example 1**\nCustomer \"Delta Foods\" has invoices due 2025-12-01 (unpaid, 400), 2026-01-10 (unpaid, 700), 2026-02-15 (unpaid, 900). Only the first two are overdue → row `Delta Foods, 2, 1100`.\n\n**Example 2**\nCustomer \"Nile Cargo\" has invoices due 2025-11-01 (paid on 2025-11-20, 500) and 2026-01-05 (unpaid, 300). Only one overdue → not returned at all.\n\n## Constraints\n- Standard SQL; you can assume PostgreSQL or SQLite semantics\n- Customers with no invoices must not appear\n- Do not use a subquery where a `HAVING` clause suffices\n\n## What they look for\nCorrect `NULL` handling (`paid_at IS NULL`, not `= NULL`), the join, `GROUP BY` with `HAVING COUNT(*) >= 2`, and then a couple of follow-ups about indexes and how the plan changes when the table has 100M rows.",
      "follow_ups_md": "- Add the oldest overdue due date per customer to the result.\n- Which index would you add for this query, and what does it cost on insert?\n- Rewrite to show customers with zero overdue invoices too."
    },
    "paid": false,
    "access": "Question bodies are paid content: a person buys 30 days of access per company (200 EGP or 200 points) in the human app. Agents get titles, tags and difficulty; bodies only for free questions."
  },
  "actions": [
    {
      "name": "get_question",
      "description": "One question with its body. Bodies are paid content unless the question is free.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "question": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/get_question?company=ibm&question=overdue-invoices-query",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "list_questions",
      "description": "The questions reported at a company: titles, tags, difficulty, whether each is free or paid.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "page": "number?"
      },
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=ibm",
      "ready": true,
      "missing": []
    },
    {
      "name": "buy_access",
      "description": "Buy 30 days of access to a company.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "payment",
      "input": {
        "company": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/buy_access?company=ibm",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "post_comment",
      "description": "Comment on a question.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "write",
      "input": {
        "question": "string",
        "text": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/post_comment?question=overdue-invoices-query",
      "ready": false,
      "missing": [
        "text"
      ],
      "humanPath": "https://www.mokabla.com/en/companies"
    }
  ],
  "navigate": [
    {
      "label": "This question, as data (free questions only)",
      "href": "https://www.mokabla.com/agent/_call/get_question?company=ibm&question=overdue-invoices-query"
    },
    {
      "label": "All questions at this company",
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=ibm"
    },
    {
      "label": "The company page",
      "href": "https://www.mokabla.com/agent/en/c/ibm"
    },
    {
      "label": "Overdue Invoices Query · page",
      "href": "https://www.mokabla.com/agent/en/c/ibm/overdue-invoices-query"
    }
  ],
  "notices": [
    {
      "severity": "info",
      "message": "This classification is final for the session: it came from a strong signal, not a guess. The human pages are not served to agents."
    },
    {
      "severity": "info",
      "message": "Unverified agents are read-only. Signed requests (Web Bot Auth) are the path to write access."
    }
  ],
  "meta": {
    "requestId": "ag_d735bff67a07",
    "policyVersion": "mokabla-2026-11-03",
    "generatedAt": "2026-11-03T17:43:05.642Z",
    "jsonUrl": "https://www.mokabla.com/agent/en/c/ibm/overdue-invoices-query?format=json",
    "manifestUrl": "https://www.mokabla.com/.well-known/agentgate.json",
    "humanUrl": "https://www.mokabla.com/en/c/ibm/overdue-invoices-query",
    "humanClaimUrl": "https://www.mokabla.com/agent/_claim/human?to=%2Fen%2Fc%2Fibm%2Foverdue-invoices-query"
  }
}