Independent synthetic fixture values, complete membership and required field types; not production or human usefulness.

Generation confidence; semantic correctness is only verified by the listed checks.

Generation confidence is not an answer certificate.

The entire question interpretation has not been independently verified.

accounts IS the canonical CT user table: accounts.id EQUALS user_id. Carries relationship_manager_id and latest_pipedrive_activity_at. A REFERRER is an account referenced by another account's affiliate_id (refer-and-earn referrer when referrer.role='User'; 'referrer(s)' is a CT concept, NEVER the Pipedrive cf_referrer custom field — same suppression as 'partners'). NAME EXPOSURE (ruling 2026-07-08): individual first/last name and company name MAY be SHOWN in result rows to anyone with vault access (the vault boundary IS the authorization) — they are filled server-side post-execution as a display column (client_name / first_name / last_name / company_name placeholders), NEVER read via model-generated SQL (the CT-leg gate rejects a physical read; the model projects `NULL AS <col>`). CONTACT PII stays intentionally NOT exposed: email, telephone/phone and IPs are never shown in results (they remain WHERE-only filters where already allowed).

Project `id AS user_id` (accounts.id is the user key); one row per user already.

System: CT

accounts

Onboarding/client dimension keyed by user_id (= accounts.id). Declared (not traded) currencies live here.

Direct user_id; one row per user_id already. Project user_id first.

System: CT

client

Semantic: federated planning failed: Logged activities live in the Pipedrive activity log, but this question groups or filters by a CurrencyTransfer-only dimension (sales stream, currency, campaign, or a live CT cohort) that only exists on the trading side — combining the two per-client isn't supported yet, and I won't silently answer with trade or referral counts instead. Try 'activity volume by owner' for the event log, or ask that breakdown against a trading measure (e.g. 'realized revenue by sales stream'). Name the group, measure, and date window in a new question.

activation-definition activation-definition-gold onboarding-duration declared-currency-intent client-type-sti-classes

How many distinct ordinary CT user accounts opted in to marketing emails whose registration is still incomplete are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

The trade's PAYMENT/LIQUIDITY PARTNER — CT calls this the BROKER (live names include Corpay, Corpay Offline, Currencycloud, Clear Treasury, Moneycorp, Verto, iBan First, Central FX). Resolve the partner NAME by joining: JOIN public.broker_accounts ba ON ba.id = tb.broker_account_id JOIN public.brokers b ON b.id = ba.broker_id, then use b.name as the partner dimension (GROUP BY b.name for a by-partner breakdown; every trade_bookings row carries broker_account_id). NEVER use trade_bookings.platform for a partner/provider/broker breakdown — platform is the booking CHANNEL (web/ios/system/nexus), not a partner — and never alias platform AS payment_partner.

Direct user_id; group trade rows to one per user_id (COUNT(*) FILTER (WHERE status <> 'closed') for the default booked trade count; a settled-gated count ONLY when the user explicitly says settled). Window REALIZED money metrics (settled commission/revenue, daily run-rate, realized QoQ) on completed_at with status='settled' — NOT settlement_at (the deadline) and NOT traded_at (booking date). Use traded_at only for booking-date questions.

System: CT

broker

signup-date mis-binding fix (created_at vs first_activated_at)

System: CT

registration date

System: CT

client

Semantic: Unverified calendar semantics: physical timestamp type or lineage is missing Use the requested calendar and the authorized physical timestamp type. Convert naive UTC storage to an instant before converting to the requested wall clock; convert timestamptz directly to that wall clock. Compare compatible timestamp types.

SELECT CAST(COUNT(DISTINCT a.id) AS INT) AS client_count FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id JOIN public.broker_accounts AS ba ON ba.user_id = a.id WHERE NOT c.completed_registration_at IS NULL AND NOT ba.verified_at IS NULL AND CAST(((ba.verified_at) AT TIME ZONE 'UTC') AT TIME ZONE 'UTC' AS DATE) > CAST(((c.completed_registration_at) AT TIME ZONE 'UTC') AT TIME ZONE 'Europe/London' AS DATE)

SELECT
  CAST(COUNT(DISTINCT a.id) AS INT) AS client_count
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
JOIN public.broker_accounts AS ba
  ON ba.user_id = a.id
WHERE
  NOT c.completed_registration_at IS NULL
  AND NOT ba.verified_at IS NULL
  AND CAST((
    (
      ba.verified_at
    ) AT TIME ZONE 'UTC'
  ) AT TIME ZONE 'UTC' AS DATE) > CAST((
    (
      c.completed_registration_at
    ) AT TIME ZONE 'UTC'
  ) AT TIME ZONE 'Europe/London' AS DATE)

activation-definition activation-definition-gold onboarding-duration churn-tier-definitions declared-currency-intent trade-existence-default-booked settlement-is-ct-trade-lifecycle client-type-sti-classes trade-existence-gold-booked

How many distinct CT accounts of any role whose earliest verified broker account date is after their completed registration date are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

broker

System: CT

client

Semantic: The query could not preserve the requested meaning or scope. Name the group, measure, and date window in a new question.

churn-tier-definitions declared-currency-intent trade-existence-default-booked settlement-is-ct-trade-lifecycle client-type-sti-classes

```json
{
  "sql": "",
  "explanation": "The schema provided does not include ct.client_360 (the only table permitted by the federation gold-leg constraint), and no column identifies a broker account previously verified but now outdated.",
  "confidence": "uncertain",
  "warnings": ["ct.client_360 c

How many distinct CT accounts of any role with a previously verified broker account now marked outdated are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

broker

System: CT

client

Sql: The generated SQL could not complete the requested query. Name the group, measure, and date window in a new question.

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a WHERE EXISTS (SELECT 1 FROM public.broker_accounts ba1 WHERE ba1.user_id = a.id AND ba1.notified_at IS NOT NULL AND ba1.deleted_at IS NULL) AND NOT EXISTS (SELECT 1 FROM public.broker_accounts ba2 WHERE ba2.user_id = a.id AND ba2.verified_at IS NOT NULL AND ba2.deleted_at IS NULL)

SELECT COUNT(*) AS client_count FROM public.accounts a WHERE EXISTS (SELECT 1 FROM public.broker_accounts b WHERE b.user_id = a.id AND b.notified_at IS NOT NULL AND b.deleted_at IS NULL) AND NOT EXISTS (SELECT 1 FROM public.broker_accounts v WHERE v.user_id = a.id AND v.verified_at IS NOT NULL)

```json
{
  "sql": "",
  "explanation": "The gold catalog contains only ct.client_360, ct.accounts, ct.activation, ct.client_revenue and pipedrive.* tables, none of which expose broker_accounts notified_at/verified_at data, so this question cannot be answered from the allowlisted relations.",
  "con

How many distinct CT accounts of any role with a notified broker account but no broker account that has ever been verified are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

brokers

System: CT

client

SELECT COUNT(*) AS client_count FROM (SELECT ba.user_id FROM public.broker_accounts ba WHERE ba.user_id IS NOT NULL AND ba.verified_at IS NOT NULL AND ba.deleted_at IS NULL GROUP BY ba.user_id HAVING COUNT(DISTINCT ba.broker_id) >= 2) q

SELECT ba.user_id AS user_id, COUNT(DISTINCT ba.broker_id) AS verified_broker_count FROM public.broker_accounts ba WHERE ba.user_id IS NOT NULL AND ba.verified_at IS NOT NULL AND ba.deleted_at IS NULL GROUP BY 1 HAVING COUNT(DISTINCT ba.broker_id) >= 2

How many distinct CT accounts of any role that have at least two different verified brokers are there? Return client_count, including zero if none qualify.

CT data unavailable: The generated SQL could not complete the requested query.


System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.clients c ON c.user_id = a.id WHERE c.type = 'PersonalAccount' AND COALESCE(array_length(c.sell_currencies, 1), 0) > 0 AND COALESCE(array_length(c.buy_currencies, 1), 0) > 0

SELECT COUNT(DISTINCT c.id) AS client_count FROM public.clients c WHERE c.type = 'private' AND c.sell_currencies IS NOT NULL AND array_length(c.sell_currencies, 1) >= 1 AND c.buy_currencies IS NOT NULL AND array_length(c.buy_currencies, 1) >= 1

How many distinct private CT client records who declared at least one currency on both the sell and buy sides are there? Return client_count, including zero if none qualify.


First returned row — client_count: 4.00.

How many distinct corporate CT client records with...

System: CT

client

Metric match

No predefined metrics are configured for this connection — scored on time clarity, query complexity and column visibility instead

Query complexity

Moderate complexity: 1 JOINs, subqueries

High confidence (85%) — moderate complexity

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.clients c ON c.user_id = a.id WHERE c.type IS NOT NULL AND c.type <> 'PersonalAccount' AND c.completed_registration_at IS NOT NULL AND NOT EXISTS (SELECT 1 FROM public.trade_bookings tb WHERE tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed')

SELECT
  COUNT(DISTINCT a.id) AS client_count
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT c.type IS NULL
  AND c.type <> 'PersonalAccount'
  AND NOT c.completed_registration_at IS NULL
  AND NOT EXISTS(
    SELECT
      1
    FROM public.trade_bookings AS tb
    WHERE
      tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed'
  )

Reading this as the registration-form funnel — started the signup wizard vs finished it (clients.completed_registration_at). If you meant activation (verified & ready to trade), say so.

Show the underlying rows for this result.

How many distinct corporate CT client records with completed registration who have no non-deleted, non-closed booking are there? Return client_count, including zero if none qualify.

Reads from accounts, clients, and trade_bookings.

Calculates how many DISTINCT a.id there are.

Keeps only rows matching filters on type, completed_registration_at, status, user_id, id, and deleted_at.

Summary: Works out how many DISTINCT a.id there are from accounts, clients, and trade_bookings.


System: CT

CT accounts

Quote-level rows with DIRECT user_id (= accounts.id). No account_id column. type is by_client/admin_ping/rate_alert/rsi_alert — a quote a user MADE = type 'by_client' only (rate-alert/RSI/admin pings are system rows, ~40% of the table). status booked/pending; a booked quote converted to a trade (trade_bookings.quote_id = quotes.id).

Direct user_id; group quote metrics to one row per user_id before merge.

System: CT

quotes

System: CT

client

Schema: The query refers to a table or column that is unavailable on the selected connection. Name a measure and source available on this connection.

WITH sys_q AS (SELECT user_id FROM public.quotes WHERE type IN ('admin_ping', 'rate_alert', 'rsi_alert') AND NOT quotes.user_id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com') GROUP BY user_id), user_q AS (SELECT user_id FROM public.quotes WHERE type = 'by_client' AND NOT quotes.user_id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com') GROUP BY user_id) SELECT COUNT(*) AS client_count FROM sys_q LEFT JOIN user_q ON user_q.user_id = sys_q.user_id WHERE user_q.user_id IS NULL

How many distinct CT accounts of any role that have system-generated quotes and no user-requested quote are there? Return client_count, including zero if none qualify.

CT data unavailable: The query refers to a table or column unavailable on the selected connection.


System: CT

client

System: CT

client type

System: CT

broker

SELECT COUNT(DISTINCT c.user_id)::bigint AS client_count FROM public.clients c WHERE c.type IS NULL AND EXISTS (SELECT 1 FROM public.broker_accounts ba WHERE ba.user_id = c.user_id AND ba.deleted_at IS NULL)

SELECT COUNT(DISTINCT c.user_id) AS client_count FROM public.clients c WHERE (c.type IS NULL OR c.type ILIKE 'unknown%') AND c.user_id IS NOT NULL AND EXISTS (SELECT 1 FROM public.broker_accounts ba WHERE ba.user_id = c.user_id)

churn-tier-definitions declared-currency-intent trade-existence-default-booked settlement-is-ct-trade-lifecycle activation-definition-gold client-type-sti-classes trade-existence-gold-booked

How many distinct CT client records whose client type is unknown and who have at least one broker account are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

quote

System: CT

quote ID

System: CT

client

SELECT COUNT(DISTINCT q.user_id) AS client_count FROM public.quotes AS q JOIN public.trade_bookings AS tb ON tb.quote_id = q.id WHERE (q.type = 'by_client' AND tb.deleted_at IS NULL AND tb.status <> 'closed') AND NOT q.user_id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com')

How many distinct CT accounts of any role whose own quote converted to a non-deleted, non-closed booking through the quote ID link are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

quote

System: CT

broker

System: CT

client

SELECT CASE WHEN COUNT(*) = 0 THEN 0 ELSE SUM(CASE WHEN q.first_quote_at < v.first_verified_at THEN 1 ELSE 0 END) END AS client_count FROM (SELECT q.user_id, MIN(q.created_at) AS first_quote_at FROM public.quotes AS q WHERE (q.type = 'by_client' AND NOT q.user_id IS NULL) AND NOT q.user_id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com') GROUP BY q.user_id) AS q JOIN (SELECT ba.user_id, MIN(ba.verified_at) AS first_verified_at FROM public.broker_accounts AS ba WHERE NOT ba.user_id IS NULL AND NOT ba.verified_at IS NULL AND ba.deleted_at IS NULL GROUP BY ba.user_id) AS v ON v.user_id = q.user_id

How many distinct CT accounts of any role whose user-requested quote predates their earliest known broker verification timestamp are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

client

```json
{
  "sql": "",
  "explanation": "The federation leg requires ct.client_360 and pipedrive.* tables, but only public.* tables are available in the schema, so I cannot generate a compliant query.",
  "confidence": "uncertain",
  "warnings": ["Requested sources (ct.client_360, pipedrive.*) are n

How many distinct CT accounts of any role with a non-deleted booking but no settled booking are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

client

Semantic: SQL still failed CTMeasureBasisError enforcement after regeneration: CT requested revenue basis is unverified: a client qualification cannot determine the revenue reading Keep the accepted client cohort unchanged. Rebuild only the requested measure: booked[path] revenue uses SUM(trade_details.commission) over its own trade_bookings.status <> 'closed', dated by traded_at; realized[path] uses status = 'settled', dated by completed_at. Link details.trade_booking_id to that booking's id. A different trade alias or EXISTS defining eligible clients does not establish the measure's status. On ct.client_360 use revenue_gbp_all for booked and revenue_gbp_settled for reali...

How many distinct CT accounts of any role with pre-billable bookings that qualify for the CT statistics filters are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

client

SELECT CAST(COUNT(DISTINCT tb.user_id) AS BIGINT) AS client_count FROM public.trade_bookings AS tb WHERE (NOT tb.invoice_at IS NULL AND NOT COALESCE(tb.status, '') IN ('closed', 'settled')) AND NOT tb.user_id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com')

SELECT COUNT(DISTINCT t.user_id) AS client_count FROM public.trade_bookings t WHERE t.user_id IS NOT NULL AND t.invoice_at IS NOT NULL AND t.status NOT IN ('closed', 'settled')

How many distinct CT accounts of any role with an invoiced booking record that is neither closed nor settled, including records marked deleted are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

client

```json
{
  "sql": "",
  "explanation": "The federation context requires drawing only from ct.client_360, but that table is not present in the provided schema, so I cannot map the required fields (account deleted flag, deleted booking flag) without inventing columns.",
  "confidence": "uncertain",

How many distinct CT accounts of any role whose account is not deleted but who have a deleted booking are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

CT realized commission in GBP — THE canonical CT revenue measure. SUM(commission) over trades whose trade_bookings.status='settled', grouped by trade_bookings.user_id. NEVER use settlement/sell/buy amount as revenue.

Join trade_booking_id -> trade_bookings.id, then GROUP BY trade_bookings.user_id. Realized GBP revenue = SUM(commission) where trade_bookings.status='settled'. Date realized-revenue windows on trade_bookings.completed_at (actual settlement date), NOT settlement_at (deadline) or traded_at (booking).

System: CT

commission

System: CT

client

Semantic: SQL still failed RequestedResultShapeError enforcement after regeneration: The requested CT grand total requires a scalar SUM of its measure; output semantics are unverified. Return one row containing the requested grand-total measure or measures. Use SUM over the verified physical measure, not AVG, ARRAY_AGG, COUNT, IDs, SUM(DISTINCT amount), or constants. Aliases alone do not prove a measure. Preserve the accepted cohort filters, fact dates, measure basis and currency units. Aggregate the verified inputs before the outer result; omit per-client and time grouping unless the question explicitly requests a breakdown. Do not use LIMIT 1, a window repeated on client row...

How many distinct CT accounts of any role whose sum of known realized commission is negative are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

GBP conversion rate for the sell leg. CT-report stats filter excludes trades where this IS NULL (commission cannot be converted to GBP).

System: CT

sell-currency-to-GBP rate

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a WHERE EXISTS (SELECT 1 FROM public.trade_bookings tb WHERE tb.user_id = a.id AND tb.status = 'settled' AND tb.deleted_at IS NULL AND tb.sell_currency_to_gbp_rate IS NULL)

SELECT COUNT(DISTINCT t.user_id) AS client_count FROM ct.trade_bookings t WHERE t.status = 'settled' AND t.sell_currency_to_gbp_rate IS NULL

How many distinct CT accounts of any role with a settled booking that has no sell-currency-to-GBP rate are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

commission

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts AS a JOIN public.trade_bookings AS tb ON tb.user_id = a.id LEFT JOIN public.trade_details AS td ON td.trade_booking_id = tb.id WHERE NOT EXISTS(SELECT 1 FROM public.trade_details AS td2 JOIN public.trade_bookings AS tb2 ON tb2.id = td2.trade_booking_id WHERE tb2.user_id = a.id AND NOT td2.commission IS NULL) AND NOT a.id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com')

SELECT tb.user_id AS user_id, COUNT(DISTINCT tb.user_id) AS client_count FROM public.trade_bookings tb JOIN public.trade_details td ON td.trade_booking_id = tb.id JOIN public.accounts a ON a.id = tb.user_id WHERE td.commission IS NULL AND td.commission_net IS NULL AND td.commission_affiliate IS NULL AND td.commission_sub_affiliate IS NULL GROUP BY tb.user_id

```json
{
  "sql": "",
  "explanation": "The gold catalog contains only ct.client_360 rollups with no commission-input fields, so the 'all commission inputs unknown' condition cannot be evaluated in this leg.",
  "confidence": "uncertain",
  "warnings": ["Commission-null detection requires public.tr

How many distinct CT accounts of any role with booking records, including closed and deleted records, whose commission inputs are all unknown are there? Return client_count, including zero if none qualify.


Generation confidence; semantic checks may be unverified.

System: CT

CT accounts

System: CT

commission

System: CT

client

Provider: The generation provider is unavailable after the bounded retry. Retry the same question when the generation provider is available.

How many distinct CT accounts of any role with at least one known booked commission input and a booked commission total of exactly zero are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

When the trade completed/settled. Date column for the realized (settled) commission reading.

System: CT

completion date

The client's settlement DEADLINE (the must-settle-by date so the payment firm honours delivery) — NOT when revenue is realized. It is populated even on trades that have not settled yet (e.g. awaiting_funds). Do NOT date realized/settled money on this; use completed_at.

System: CT

settlement deadline

System: CT

client

Semantic: SQL still failed CalendarSemanticsError enforcement after regeneration: Unverified calendar semantics: more than one requested timezone Use the requested calendar and the authorized physical timestamp type. Convert naive UTC storage to an instant before converting to the requested wall clock; convert timestamptz directly to that wall clock. Compare compatible timestamp types.

How many distinct CT accounts of any role with a settled booking whose actual completion date differs from its settlement deadline date in Europe/London, treating raw timestamps as UTC are there? Return client_count, including zero if none qualify.


System: CT

accounts

System: CT

client

How many distinct ordinary CT user accounts created during September 2026 in Europe/London, interpreting raw timestamps as UTC are there? Return client_count, including zero if none qualify.


First returned row — client_count: 11.00.

How many distinct CT client records referred by a ...

System: CT

client

Matview over public.affiliate_details. AFFILIATE-keyed dimension (keyed by affiliate_id), NOT a per-user/client fact table. It bridges to a client via client.affiliate_id = affiliate_details.affiliate_id, where client.affiliate_id -> accounts.id of the referrer (NOT the account_id bridge). One affiliate maps to many clients, so it CANNOT merge on the federation user_id; route it as an affiliate-dimension lookup (fail-safe), never fanned out or summed per user, until a hand-tuned attribution bridge exists. Refer-and-earn referrers are accounts.role='User' (accounts.role values include User 89179, Affiliate 442, Partner 50, AffiliateManager 11); commission_rate > 0 marks a professional affiliate. SECURITY: bank/PII columns (iban, account_number, sort_code, bic_swift, aba, bsb, address, bank_account_country) are never exposed in a CT federation leg.

System: CT

professional affiliate

Affiliate commission rate; commission_rate > 0 marks a professional affiliate.

System: CT

commission rate

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.accounts ref ON ref.id = a.affiliate_id JOIN public.affiliate_details ad ON ad.affiliate_id = ref.id JOIN public.clients c ON c.user_id = a.id WHERE a.affiliate_id IS NOT NULL AND ref.role IN ('Affiliate','AffiliateManager','Partner') AND ad.commission_rate = 0

SELECT
  COUNT(DISTINCT a.id) AS client_count
FROM public.accounts AS a
JOIN public.accounts AS ref
  ON ref.id = a.affiliate_id
JOIN public.affiliate_details AS ad
  ON ad.affiliate_id = ref.id
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT a.affiliate_id IS NULL
  AND ref.role IN ('Affiliate', 'AffiliateManager', 'Partner')
  AND ad.commission_rate = 0

Assuming "revenue" = booked trading revenue (commission on all non-cancelled trades) — includes open/forward trades not yet settled — say 'settled', 'realized', or 'billable' to narrow.

refer-and-earn-earnings-disambiguation affiliate-cohort-designator settlement-is-ct-trade-lifecycle declared-currency-intent client-type-sti-classes

How many distinct CT client records referred by a professional affiliate whose commission rate is zero are there? Return client_count, including zero if none qualify.

Reads from accounts, affiliate_details, and clients.

Keeps only rows matching filters on commission_rate, role, and affiliate_id.

Summary: Works out how many DISTINCT a.id there are from accounts, affiliate_details, and clients.


Question: Rerun the previous question, or name the group.

How many distinct CT client records referred by a customer account where that referrer has a reward event for the same client are there? Return client_count, including zero if none qualify.


System: CT

CT accounts

System: CT

broker

System: CT

client

SELECT CAST(COUNT(*) AS INT) AS client_count FROM (SELECT a.id FROM public.accounts AS a JOIN (SELECT user_id, MIN(traded_at) AS first_booking_at FROM public.trade_bookings WHERE (deleted_at IS NULL AND status <> 'closed' AND NOT traded_at IS NULL) AND NOT trade_bookings.user_id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com') GROUP BY user_id) AS ft ON ft.user_id = a.id JOIN (SELECT user_id, MIN(verified_at) AS first_verified_at FROM public.broker_accounts WHERE NOT verified_at IS NULL GROUP BY user_id) AS fv ON fv.user_id = a.id WHERE a.deleted_at IS NULL AND ft.first_booking_at < fv.first_verified_at) AS q

SELECT COUNT(*) AS client_count FROM (SELECT tb.user_id, MIN(tb.traded_at) FILTER (WHERE tb.status <> 'closed' AND tb.deleted_at IS NULL) AS first_booking FROM public.trade_bookings tb GROUP BY 1) f JOIN LATERAL (SELECT MIN(ba.verified_at) AS first_verification FROM public.broker_accounts ba WHERE ba.user_id = f.user_id AND ba.deleted_at IS NULL) v ON TRUE WHERE f.first_booking IS NOT NULL AND v.first_verification IS NOT NULL AND f.first_booking < v.first_verification)

How many distinct CT accounts of any role whose first non-deleted, non-closed booking predates their first broker verification are there? Return client_count, including zero if none qualify.


First returned row — client_count: 3.00.

How many distinct professional CT partner accounts...

System: CT

partner

System: CT

accounts

System: CT

client

SELECT COUNT(*) AS client_count FROM ( SELECT s.affiliate_id FROM public.affiliate_commission_statements s JOIN public.accounts ref ON ref.id = s.affiliate_id WHERE ref.role IN ('Affiliate','AffiliateManager','Partner') AND ref.deleted_at IS NULL GROUP BY s.affiliate_id HAVING COUNT(*) FILTER (WHERE s.paid_at IS NOT NULL) > 0 AND COUNT(*) FILTER (WHERE s.paid_at IS NULL) > 0 ) q

SELECT
  COUNT(*) AS client_count
FROM (
  SELECT
    s.affiliate_id
  FROM public.affiliate_commission_statements AS s
  JOIN public.accounts AS ref
    ON ref.id = s.affiliate_id
  WHERE
    ref.role IN ('Affiliate', 'AffiliateManager', 'Partner')
    AND ref.deleted_at IS NULL
  GROUP BY
    s.affiliate_id
  HAVING
    COUNT(*) FILTER(WHERE
      NOT s.paid_at IS NULL) > 0
    AND COUNT(*) FILTER(WHERE
      s.paid_at IS NULL) > 0
) AS q

Compare client count with the previous period.

How many distinct professional CT partner accounts with both paid and unpaid monthly affiliate statements are there? Return client_count, including zero if none qualify.

Reads from affiliate_commission_statements and accounts.

Summary: Works out how many rows there are from affiliate_commission_statements and accounts.


First returned row — client_count: 43.00.

How many distinct CT accounts of any role assigned...

System: CT

CT accounts

System: CT

client

Medium confidence (69%) — implicit time period, moderate complexity

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.user_analytics ua ON ua.user_id = a.id WHERE a.campaign_id IS NOT NULL AND NULLIF(TRIM(ua.came_from_domain), '') IS NOT NULL

SELECT
  COUNT(DISTINCT a.id) AS client_count
FROM public.accounts AS a
JOIN public.user_analytics AS ua
  ON ua.user_id = a.id
WHERE
  NOT a.campaign_id IS NULL AND NOT NULLIF(TRIM(ua.came_from_domain), '') IS NULL

How many distinct CT accounts of any role assigned to a campaign and with a known web referral domain are there? Return client_count, including zero if none qualify.

Keeps only rows matching filters on campaign_id and came_from_domain.

Summary: Works out how many DISTINCT a.id there are from accounts and user_analytics.


System: CT

accounts

Owning salesperson id (account-level). Used alongside relationship_manager_id to assign a client's sales 'stream'/team.

System: CT

salesperson

Owning relationship manager id (account-level).

System: CT

relationship manager

System: PD

people

System: CT

client

SELECT COUNT(*) AS client_count FROM public.accounts WHERE public.accounts.salesperson_id IS NOT NULL AND public.accounts.relationship_manager_id IS NOT NULL AND public.accounts.salesperson_id <> public.accounts.relationship_manager_id AND public.accounts.role = 'User'

SELECT COUNT(*) AS client_count FROM public.accounts WHERE salesperson_id IS NOT NULL AND relationship_manager_id IS NOT NULL AND salesperson_id <> relationship_manager_id

How many distinct ordinary CT user accounts whose salesperson and relationship manager are both known and are different people are there? Return client_count, including zero if none qualify.


First returned row — client_count: 16.00.

How many distinct ordinary CT user accounts with c...

System: CT

accounts

Identity placeholder — NEVER select the physical column in SQL (the validator rejects it): project `NULL AS first_name`; the server fills real values post-execution keyed on user_id.

System: CT

first-name

Identity placeholder — NEVER select the physical column in SQL (the validator rejects it): project `NULL AS last_name`; the server fills real values post-execution keyed on user_id.

System: CT

last-name

Identity placeholder — NEVER select the physical column in SQL (the validator rejects it): project `NULL AS telephone`; the server fills real values post-execution keyed on user_id.

System: CT

telephone

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count, NULL AS phone FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE NOT c.completed_registration_at IS NULL AND (a.role = 'User' OR a.role IS NULL) AND (NULLIF(TRIM(a.first_name), '') IS NULL OR NULLIF(TRIM(a.last_name), '') IS NULL OR NULLIF(TRIM(a.telephone), '') IS NULL)

SELECT
  COUNT(DISTINCT a.id) AS client_count,
  NULL AS phone
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT c.completed_registration_at IS NULL
  AND (
    a.role = 'User' OR a.role IS NULL
  )
  AND (
    NULLIF(TRIM(a.first_name), '') IS NULL
    OR NULLIF(TRIM(a.last_name), '') IS NULL
    OR NULLIF(TRIM(a.telephone), '') IS NULL
  )

How many distinct ordinary CT user accounts with complete registration but at least one missing or blank first-name, last-name, or telephone field are there? Return client_count, including zero if none qualify.

Keeps only rows matching filters on completed_registration_at, role, telephone, first_name, and last_name.

Summary: Works out how many DISTINCT a.id there are from accounts and clients.


System: CT

client

System: CT

sell currency

DECLARED (onboarding) sell currencies — the currencies the client SAID at sign-up they wanted to sell. NOT actually-traded (that is trade_bookings.sell_currency/buy_currency) and NOT a residence cohort. An ARRAY (text[]): test membership with `'<CODE>' = ANY(clients.sell_currencies)`; there is NO singular sell_currency column on clients and a scalar comparison fails validation. Declared intent needs NO trade — a client who never traded still has one — so never add a trade-existence predicate to a declared-intent cohort. A generic 'declared/intended to trade <CODE>' is EITHER side: OR this with ct.clients.buy_currencies; '<CODE> book' is the TRADED cohort, a different lens.

System: CT

declared sell currencies

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id JOIN public.trade_bookings AS tb ON tb.user_id = a.id WHERE (tb.deleted_at IS NULL AND tb.status <> 'closed' AND NOT tb.sell_currency IS NULL AND NOT (tb.sell_currency = ANY(c.sell_currencies))) AND NOT a.id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com')

SELECT COUNT(DISTINCT c.id) AS client_count FROM public.clients c JOIN public.trade_bookings tb ON tb.user_id = c.user_id AND tb.deleted_at IS NULL AND tb.status <> 'closed' WHERE c.sell_currencies IS NULL OR NOT (tb.sell_currency = ANY (c.sell_currencies))

```json
{
  "sql": "",
  "explanation": "This question requires comparing each trade's sell currency against the client's declared sell currencies, but the gold catalog contains no raw trade_bookings or clients table, and ct.client_360 exposes no trade-currency-mismatch rollup.",
  "confidence": "un

How many distinct CT client records who booked a non-deleted, non-closed trade in a sell currency absent from their declared sell currencies are there? Return client_count, including zero if none qualify.


First returned row — client_count: 2.00.

How many distinct private CT client records whose ...

System: CT

client

System: CT

broker

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.clients c ON c.user_id = a.id WHERE c.type = 'PersonalAccount' AND c.status = 'rejected' AND EXISTS (SELECT 1 FROM public.broker_accounts ba WHERE ba.user_id = a.id AND ba.verified_at IS NOT NULL)

SELECT
  COUNT(DISTINCT a.id) AS client_count
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  c.type = 'PersonalAccount'
  AND c.status = 'rejected'
  AND EXISTS(
    SELECT
      1
    FROM public.broker_accounts AS ba
    WHERE
      ba.user_id = a.id AND NOT ba.verified_at IS NULL
  )

activation-definition activation-definition-gold onboarding-duration churn-tier-definitions declared-currency-intent trade-existence-default-booked settlement-is-ct-trade-lifecycle client-type-sti-classes

How many distinct private CT client records whose registration status is rejected but whose broker verification timestamp exists are there? Return client_count, including zero if none qualify.

Reads from accounts, clients, and broker_accounts.

Keeps only rows matching filters on type, status, user_id, id, and verified_at.

Summary: Works out how many DISTINCT a.id there are from accounts, clients, and broker_accounts.


First returned row — client_count: 0.00.

No complete question-to-answer semantic oracle was run.

SQL checks do not prove the whole question interpretation.

How many distinct Pipedrive people with a deal ass...

System: PD

people

System: PD

organization

System: CT

client

SELECT COUNT(DISTINCT d.person_id) AS client_count FROM pipedrive.deals d JOIN pipedrive.persons_enriched pe ON pe.id = d.person_id WHERE d.person_id IS NOT NULL AND d.org_id IS NOT NULL AND pe.org_id IS NOT NULL AND d.org_id <> pe.org_id AND pe.pd_is_ct_employee IS NOT TRUE

SELECT
  COUNT(DISTINCT d.person_id) AS client_count
FROM pipedrive.deals AS d
JOIN pipedrive.persons_enriched AS pe
  ON pe.id = d.person_id
WHERE
  NOT d.person_id IS NULL
  AND NOT d.org_id IS NULL
  AND NOT pe.org_id IS NULL
  AND d.org_id <> pe.org_id
  AND NOT pe.pd_is_ct_employee IS TRUE

How many distinct Pipedrive people with a deal assigned to a different organization from their person record are there? Return client_count, including zero if none qualify.

Calculates how many DISTINCT d.person_id there are.

Keeps only rows matching filters on org_id, pd_is_ct_employee, and person_id.

Summary: Works out how many DISTINCT d.person_id there are from deals and persons_enriched.


System: PD

people

System: PD

owner

System: PD

organization

System: CT

client

How many distinct Pipedrive people whose owner differs from the owner of their organization are there? Return client_count, including zero if none qualify.


How many distinct Pipedrive people who have a lead...

System: PD

people

System: PD

stage

System: CT

client

SELECT COUNT(DISTINCT pe.id) AS client_count FROM pipedrive.persons_enriched pe WHERE pe.pd_lead_qualified_at IS NOT NULL AND NOT EXISTS (SELECT 1 FROM pipedrive.deals d WHERE d.person_id = pe.id AND d.stage_name = 'Negotiation')

SELECT
  COUNT(DISTINCT pe.id) AS client_count
FROM pipedrive.persons_enriched AS pe
WHERE
  NOT pe.pd_lead_qualified_at IS NULL
  AND NOT EXISTS(
    SELECT
      1
    FROM pipedrive.deals AS d
    WHERE
      d.person_id = pe.id AND d.stage_name = 'Negotiation'
  )

How many distinct Pipedrive people who have a lead qualification date but no deal in the Negotiation stage are there? Return client_count, including zero if none qualify.

Calculates how many DISTINCT pe.id there are.

Keeps only rows matching filters on pd_lead_qualified_at, person_id, id, and stage_name.

Summary: Works out how many DISTINCT pe.id there are from persons_enriched and deals.


First returned row — client_count: 22.00.

How many distinct Pipedrive people with an active ...

System: PD

people

System: CT

client

Simple single-table query with basic aggregation

SELECT COUNT(DISTINCT n.person_id)::bigint AS client_count FROM pipedrive.notes n WHERE n.person_id IS NOT NULL AND n.active_flag = TRUE AND n.pinned_to_person_flag = TRUE AND COALESCE(n.pinned_to_deal_flag, FALSE) = FALSE

SELECT
  CAST(COUNT(DISTINCT n.person_id) AS BIGINT) AS client_count
FROM pipedrive.notes AS n
WHERE
  NOT n.person_id IS NULL
  AND n.active_flag = TRUE
  AND n.pinned_to_person_flag = TRUE
  AND COALESCE(n.pinned_to_deal_flag, FALSE) = FALSE

How many distinct Pipedrive people with an active note pinned to the person but not pinned to a deal are there? Return client_count, including zero if none qualify.

Calculates how many DISTINCT n.person_id there are.

Keeps only rows matching filters on pinned_to_person_flag, pinned_to_deal_flag, active_flag, and person_id.

Summary: Works out how many DISTINCT n.person_id there are from notes.


How many distinct Pipedrive people with an open de...

System: PD

people

System: CT

client

Time clarity

Explicit time period specified: 'september'

High confidence (100%) — clear time period, simple query

SELECT COUNT(DISTINCT d.person_id) AS client_count FROM pipedrive.deals d WHERE d.status = 'open' AND d.expected_close_date < DATE '2026-09-01' AND d.close_time IS NULL

SELECT
  COUNT(DISTINCT d.person_id) AS client_count
FROM pipedrive.deals AS d
WHERE
  d.status = 'open'
  AND d.expected_close_date < CAST('2026-09-01' AS DATE)
  AND d.close_time IS NULL

How many distinct Pipedrive people with an open deal expected to close before 1 September 2026 but with no actual close timestamp are there? Return client_count, including zero if none qualify.

Keeps only rows matching filters on close_time, status, and expected_close_date.

Summary: Works out how many DISTINCT d.person_id there are from deals.


First returned row — client_count: 54.00.

How many distinct Pipedrive people with an activit...

System: PD

people

System: PD

activity

System: PD

due date

System: CT

client

SELECT COUNT(DISTINCT a.person_id)::bigint AS client_count FROM pipedrive.activities a WHERE a.person_id IS NOT NULL AND a.due_date IS NOT NULL AND a.add_time IS NOT NULL AND a.due_date < a.add_time::date

SELECT
  CAST(COUNT(DISTINCT a.person_id) AS BIGINT) AS client_count
FROM pipedrive.activities AS a
WHERE
  NOT a.person_id IS NULL
  AND NOT a.due_date IS NULL
  AND NOT a.add_time IS NULL
  AND a.due_date < CAST(a.add_time AS DATE)

How many distinct Pipedrive people with an activity whose due date precedes its creation date are there? Return client_count, including zero if none qualify.

Calculates how many DISTINCT a.person_id there are.

Keeps only rows matching filters on due_date, add_time, and person_id.

Summary: Works out how many DISTINCT a.person_id there are from activities.


System: PD

people

System: PD

organization

System: PD

company introducer

System: CT

client

SELECT COUNT(DISTINCT public.accounts.id)::numeric AS client_count FROM public.accounts

SELECT c.user_id, COUNT(DISTINCT pe.id) FILTER (WHERE o.cf_company_introducer_org_id IS NOT NULL AND pd_is_ct_employee IS NOT TRUE) AS client_count FROM ct.client_360 c LEFT JOIN pipedrive.persons_enriched pe ON pe.ct_id = c.user_id LEFT JOIN pipedrive.organizations o ON o.id = pe.org_id GROUP BY 1

How many distinct Pipedrive people at an organization whose company introducer is another known organization are there? Return client_count, including zero if none qualify.


First returned row — client_count: 32.00.

How many distinct Pipedrive people whose contact p...

System: PD

people

System: CT

phone

System: CT

client

SELECT COUNT(*) FILTER(WHERE 'email' = ANY(pd_contact_preferences) AND NOT ('phone' = ANY(pd_contact_preferences))) AS client_count, NULL AS email, NULL AS phone FROM pipedrive.persons_enriched

SELECT
  COUNT(*) FILTER(WHERE
    'email' = ANY(
      pd_contact_preferences
    )
    AND NOT (
      'phone' = ANY(
        pd_contact_preferences
      )
    )) AS client_count,
  NULL AS email,
  NULL AS phone
FROM pipedrive.persons_enriched

How many distinct Pipedrive people whose contact preference array includes email but not phone are there? Return client_count, including zero if none qualify.

Reads from persons_enriched.
Calculates how many rows there are.

Summary: Works out how many rows there are from persons_enriched.


System: PD

people

System: PD

organization

System: PD

employee count

System: PD

people count

System: CT

client

How many distinct Pipedrive people whose organization has a known positive employee count but an unknown people count are there? Return client_count, including zero if none qualify.


System: PD

people

Declared intended trading frequency captured at onboarding (synced onward to Pipedrive).

System: CT

trade frequency

System: CT

client

SELECT COUNT(*) AS client_count FROM (SELECT c.user_id FROM public.clients c WHERE c.user_id IS NOT NULL AND c.trade_frequency IS NOT NULL GROUP BY c.user_id HAVING COUNT(DISTINCT c.trade_frequency) > 1) x

SELECT c.user_id, COUNT(DISTINCT p.id) FILTER (WHERE array_length(p.pd_trade_frequency, 1) > 1) AS client_count FROM ct.client_360 c JOIN pipedrive.persons_enriched p ON p.ct_id = c.user_id GROUP BY 1

How many distinct Pipedrive people who declared more than one trade frequency are there? Return client_count, including zero if none qualify.


System: PD

people

System: PD

organization

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a

SELECT COUNT(DISTINCT pe.id) FILTER (WHERE o.id IS NOT NULL AND array_length(o.cf_booking_hedging_policy, 1) > 1) AS client_count FROM ct.client_360 c LEFT JOIN pipedrive.persons_enriched pe ON pe.ct_id = c.user_id AND pe.pd_is_ct_employee IS NOT TRUE LEFT JOIN pipedrive.organizations o ON o.id = pe.org_id

How many distinct Pipedrive people whose organization declares more than one booking or hedging policy are there? Return client_count, including zero if none qualify.


System: PD

people

System: PD

activity

System: PD

owner

System: CT

client

SELECT COUNT(DISTINCT a.person_id)::bigint AS client_count FROM pipedrive.activities a JOIN pipedrive.deals d ON d.id = a.deal_id WHERE a.person_id IS NOT NULL AND a.assigned_to_user_id IS NOT NULL AND d.owner_id IS NOT NULL AND a.assigned_to_user_id <> d.owner_id

SELECT
  CAST(COUNT(DISTINCT a.person_id) AS BIGINT) AS client_count
FROM pipedrive.activities AS a
JOIN pipedrive.deals AS d
  ON d.id = a.deal_id
WHERE
  NOT a.person_id IS NULL
  AND NOT a.assigned_to_user_id IS NULL
  AND NOT d.owner_id IS NULL
  AND a.assigned_to_user_id <> d.owner_id

How many distinct Pipedrive people with an activity assigned to someone other than the owner of its deal are there? Return client_count, including zero if none qualify.

Keeps only rows matching filters on assigned_to_user_id, owner_id, and person_id.

Summary: Works out how many DISTINCT a.person_id there are from activities and deals.


System: PD

people

System: PD

organization

System: PD

LinkedIn

System: PD

website

System: CT

client

SELECT c.user_id FROM ct.client_360 AS c JOIN pipedrive.persons_enriched AS pe ON pe.ct_id = c.user_id JOIN pipedrive.organizations AS o ON o.id = pe.org_id WHERE NOT o.linkedin IS NULL AND o.website IS NULL GROUP BY c.user_id LIMIT 10000

How many distinct Pipedrive people at an organization with a LinkedIn page and no website are there? Return client_count, including zero if none qualify.


System: PD

people

Client sign-up / registration timestamp.

System: CT

signup date

Onboarding/client dimension keyed by user_id (= accounts.id). Declared (not traded) currencies live here.

System: CT

client

How many distinct Pipedrive people explicitly marked as non-employees whose lead qualification date follows their signup date are there? Return client_count, including zero if none qualify.


System: PD

people

System: PD

owner

System: CT

client

SELECT COUNT(DISTINCT n.person_id) AS client_count FROM pipedrive.notes n JOIN pipedrive.deals d ON d.id = n.deal_id WHERE n.active_flag IS TRUE AND n.person_id IS NOT NULL AND n.author_user_id IS NOT NULL AND n.author_user_id <> d.owner_id

SELECT
  COUNT(DISTINCT n.person_id) AS client_count
FROM pipedrive.notes AS n
JOIN pipedrive.deals AS d
  ON d.id = n.deal_id
WHERE
  n.active_flag IS TRUE
  AND NOT n.person_id IS NULL
  AND NOT n.author_user_id IS NULL
  AND n.author_user_id <> d.owner_id

How many distinct Pipedrive people with an active deal note authored by someone other than the deal owner are there? Return client_count, including zero if none qualify.

Keeps only rows matching filters on author_user_id, owner_id, active_flag, and person_id.

Summary: Works out how many DISTINCT n.person_id there are from notes and deals.


System: PD

people

System: PD

organization

System: CT

client

SELECT pe.ct_id AS user_id, COUNT(DISTINCT pe.id) AS client_count FROM pipedrive.persons_enriched pe JOIN pipedrive.organizations o ON o.id = pe.org_id JOIN ct.client_360 c ON c.user_id = pe.ct_id WHERE pe.pd_is_ct_employee IS NOT TRUE AND COALESCE(array_length(o.cf_erp, 1), 0) >= 2 GROUP BY pe.ct_id

How many distinct Pipedrive people whose organization names at least two ERP systems are there? Return client_count, including zero if none qualify.


System: PD

people

System: PD

activity

System: PD

duration

System: PD

due time

System: CT

client

SELECT COUNT(DISTINCT a.person_id)::bigint AS client_count FROM pipedrive.activities a WHERE a.duration IS NOT NULL AND (a.due_time IS NULL OR a.due_time = '')

SELECT
  CAST(COUNT(DISTINCT a.person_id) AS BIGINT) AS client_count
FROM pipedrive.activities AS a
WHERE
  NOT a.duration IS NULL AND (
    a.due_time IS NULL OR a.due_time = ''
  )

How many distinct Pipedrive people with an activity that has a duration but no due time are there? Return client_count, including zero if none qualify.

Keeps only rows matching filters on duration and due_time.


13 rows returned. Only the first 12 returned rows are available for this summary.

Keyed merge and authoritative-source checks.

Keys, merge grain, and source membership were checked.

How many distinct Pipedrive people at an organizat...

System: PD

people

System: PD

organization

System: PD

wallet-share

System: CT

System: CT

System: PD

System: both

System: PD

value

System: CT

client

Query times are separate. Source refresh time is unknown unless supplied.

SELECT c360.user_id, o.name AS org_name, o.cf_level_of_service, o.cf_wallet_share FROM ct.client_360 AS c360 JOIN pipedrive.persons_enriched AS pe ON pe.ct_id = c360.user_id JOIN pipedrive.organizations AS o ON o.id = pe.org_id WHERE NOT o.cf_level_of_service IS NULL AND o.cf_wallet_share IS NULL GROUP BY c360.user_id, o.name, o.cf_level_of_service, o.cf_wallet_share LIMIT 10001

SELECT a.id AS user_id FROM public.accounts AS a WHERE a.deleted_at IS NULL GROUP BY 1 LIMIT 10001

Measures retain their source and basis; they are not summed across sources.

Missing values occur in 12 of the 12 rows examined.

churn-tier-definitions declared-currency-intent activation-definition-gold client-type-sti-classes trade-existence-gold-booked

How many distinct Pipedrive people at an organization with a known service level but an unknown wallet-share value are there? Return client_count, including zero if none qualify.

Gold / Pipedrive: Reads from client_360, persons_enriched, and organizations.

Gold / Pipedrive: Keeps only rows matching filters on cf_wallet_share and cf_level_of_service.

Gold / Pipedrive: Groups the results by user_id, name, cf_level_of_service, and cf_wallet_share.

CT Ledger: Keeps only rows matching filters on deleted_at.

Summary: Combines the source results. Gold / Pipedrive: Reads rows from client_360, persons_enriched, and organizations grouped by user_id, name, cf_level_of_service, and cf_wallet_share. CT Ledger: Reads rows from accounts grouped by id.


First returned row — client_count: 44.00.

How many distinct Pipedrive people with a deal who...

System: PD

people

System: PD

stage

System: CT

client

SELECT COUNT(DISTINCT d.person_id) AS client_count FROM pipedrive.deals d WHERE d.person_id IS NOT NULL AND d.stage_change_time IS NOT NULL AND d.add_time IS NOT NULL AND d.stage_change_time < d.add_time

SELECT
  COUNT(DISTINCT d.person_id) AS client_count
FROM pipedrive.deals AS d
WHERE
  NOT d.person_id IS NULL
  AND NOT d.stage_change_time IS NULL
  AND NOT d.add_time IS NULL
  AND d.stage_change_time < d.add_time

How many distinct Pipedrive people with a deal whose stage-change timestamp predates its creation timestamp are there? Return client_count, including zero if none qualify.

Calculates how many DISTINCT d.person_id there are.

Keeps only rows matching filters on stage_change_time, add_time, and person_id.


First returned row — client_count: 1.00.

System: PD

people

System: PD

organization

System: CT

client-type

System: CT

client

SELECT c.user_id, COUNT(DISTINCT pe.id) FILTER (WHERE array_length(o.cf_client_type_tags, 1) > 1)::int AS client_count FROM ct.client_360 c LEFT JOIN pipedrive.persons_enriched pe ON pe.ct_id = c.user_id LEFT JOIN pipedrive.organizations o ON o.id = pe.org_id GROUP BY 1 LIMIT 10001

SELECT a.id AS user_id FROM public.accounts AS a WHERE a.deleted_at IS NULL LIMIT 10001

45 rows returned. Only the first 12 returned rows are available for this summary.

How many distinct Pipedrive people at an organization with more than one client-type tag are there? Return client_count, including zero if none qualify.

Gold / Pipedrive: Calculates how many DISTINCT pe.id there are.

Gold / Pipedrive: Groups the results by user_id.

Summary: Combines the source results. Gold / Pipedrive: Works out how many DISTINCT pe.id there are from client_360, persons_enriched, and organizations grouped by user_id. CT Ledger: Reads rows from accounts.


First returned row — email: synthetic-40@example.invalid.

List every distinct ordinary CT user accounts opte...

accounts IS the canonical CT user table: accounts.id EQUALS user_id. Carries relationship_manager_id and latest_pipedrive_activity_at. A REFERRER is an account referenced by another account's affiliate_id (refer-and-earn referrer when referrer.role='User'; 'referrer(s)' is a CT concept, NEVER the Pipedrive cf_referrer custom field — same suppression as 'partners'). NAME EXPOSURE (ruling 2026-07-08): individual first/last name and company name MAY be SHOWN in result rows to anyone with vault access (the vault boundary IS the authorization) — they are filled server-side post-execution as a display column (client_name / first_name / last_name / company_name placeholders), NEVER read via model-generated SQL (the CT-leg gate rejects a physical read; the model projects `NULL AS <col>`). CONTACT PII stays intentionally NOT exposed: email, telephone/phone and IPs are never shown in results (they remain WHERE-only filters where already allowed).

System: CT

accounts

System: CT

System: PD

person ID

Fictional Company 40
cfx (corporate)
synthetic-40@example.invalid

Fictional Company 53
unknown
synthetic-53@example.invalid

Fictional Company 6
cfx (corporate)
synthetic-6@example.invalid

Fictional Company 60
cfx (corporate)
synthetic-60@example.invalid

Fictional Company 21
cfx (corporate)
synthetic-21@example.invalid

Fictional Company 48
cfx (corporate)
synthetic-48@example.invalid

Fictional Company 31
cfx (corporate)
synthetic-31@example.invalid

Fictional Company 32
cfx (corporate)
synthetic-32@example.invalid

Fictional Company 39
cfx (corporate)
synthetic-39@example.invalid

Fictional Company 55
cfx (corporate)
synthetic-55@example.invalid

Fictional Company 14
cfx (corporate)
synthetic-14@example.invalid

Fictional Company 35
unknown
synthetic-35@example.invalid

Fictional Company 64
cfx (corporate)
synthetic-64@example.invalid

Fictional Company 7
cfx (corporate)
synthetic-7@example.invalid

Fictional Company 26
unknown
synthetic-26@example.invalid

Fictional Company 24
cfx (corporate)
synthetic-24@example.invalid

Fictional Company 56
cfx (corporate)
synthetic-56@example.invalid

Fictional Company 16
cfx (corporate)
synthetic-16@example.invalid

Fictional Company 8
unknown
synthetic-8@example.invalid

Fictional Company 22
cfx (corporate)
synthetic-22@example.invalid

Fictional Company 28
cfx (corporate)
synthetic-28@example.invalid

Fictional Company 5
cfx (corporate)
synthetic-5@example.invalid

Fictional Company 30
cfx (corporate)
synthetic-30@example.invalid

Fictional Company 43
cfx (corporate)
synthetic-43@example.invalid

Fictional Company 33
cfx (corporate)
synthetic-33@example.invalid

Fictional Company 11
cfx (corporate)
synthetic-11@example.invalid

Fictional Company 37
cfx (corporate)
synthetic-37@example.invalid

Fictional Company 13
cfx (corporate)
synthetic-13@example.invalid

Fictional Company 61
cfx (corporate)
synthetic-61@example.invalid

Fictional Company 4
cfx (corporate)
synthetic-4@example.invalid

Fictional Company 50
cfx (corporate)
synthetic-50@example.invalid

Fictional Company 20
cfx (corporate)
synthetic-20@example.invalid

Fictional Company 49
cfx (corporate)
synthetic-49@example.invalid

Fictional Company 15
cfx (corporate)
synthetic-15@example.invalid

Fictional Company 10
cfx (corporate)
synthetic-10@example.invalid

Fictional Company 52
cfx (corporate)
synthetic-52@example.invalid

Fictional Company 25
cfx (corporate)
synthetic-25@example.invalid

Fictional Company 3
cfx (corporate)
synthetic-3@example.invalid

Fictional Company 44
unknown
synthetic-44@example.invalid

Fictional Company 47
cfx (corporate)
synthetic-47@example.invalid

Fictional Company 59
cfx (corporate)
synthetic-59@example.invalid

Fictional Company 12
cfx (corporate)
synthetic-12@example.invalid

Fictional Company 42
cfx (corporate)
synthetic-42@example.invalid

Fictional Company 41
cfx (corporate)
synthetic-41@example.invalid

Fictional Company 62
unknown
synthetic-62@example.invalid

SELECT DISTINCT user_id, NULL AS email FROM ct.client_360 WHERE NOT user_id IS NULL LIMIT 10000

Returned row 2 — email: synthetic-53@example.invalid.

Returned row 3 — email: synthetic-6@example.invalid.

activation-definition activation-definition-gold onboarding-duration churn-tier-definitions trade-existence-gold-booked

```json
{
  "sql": "",
  "explanation": "No table in the provided schema carries a marketing-email opt-in flag or a registration-completeness status, so this cannot be answered without inventing columns.",
  "confidence": "uncertain",
  "warnings": [
    "Missing columns: marketing email opt-in and

List every distinct ordinary CT user accounts opted in to marketing emails whose registration is still incomplete. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.

Keeps only rows matching filters on user_id.

Summary: Reads rows from client_360.


26 rows returned. Only the first 12 returned rows are available for this summary.

List every distinct CT accounts of any role whose ...

System: CT

CT accounts

The trade's PAYMENT/LIQUIDITY PARTNER — CT calls this the BROKER (live names include Corpay, Corpay Offline, Currencycloud, Clear Treasury, Moneycorp, Verto, iBan First, Central FX). Resolve the partner NAME by joining: JOIN public.broker_accounts ba ON ba.id = tb.broker_account_id JOIN public.brokers b ON b.id = ba.broker_id, then use b.name as the partner dimension (GROUP BY b.name for a by-partner breakdown; every trade_bookings row carries broker_account_id). NEVER use trade_bookings.platform for a partner/provider/broker breakdown — platform is the booking CHANNEL (web/ios/system/nexus), not a partner — and never alias platform AS payment_partner.

System: CT

broker

System: CT

registration date

System: CT

System: PD

person ID

SELECT DISTINCT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE NOT c.completed_registration_at IS NULL AND EXISTS(SELECT 1 FROM public.broker_accounts AS ba WHERE ba.user_id = a.id AND NOT ba.verified_at IS NULL AND ba.verified_at > c.completed_registration_at) ORDER BY 1 LIMIT 10000

SELECT DISTINCT
  a.id AS user_id
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT c.completed_registration_at IS NULL
  AND EXISTS(
    SELECT
      1
    FROM public.broker_accounts AS ba
    WHERE
      ba.user_id = a.id
      AND NOT ba.verified_at IS NULL
      AND ba.verified_at > c.completed_registration_at
  )
ORDER BY
  1
LIMIT 10000

activation-definition activation-definition-gold onboarding-duration churn-tier-definitions trade-existence-default-booked settlement-is-ct-trade-lifecycle trade-existence-gold-booked

List every distinct CT accounts of any role whose earliest verified broker account date is after their completed registration date. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.

Reads from accounts, clients, and broker_accounts.

Keeps only rows matching filters on completed_registration_at, verified_at, user_id, and id.

Summary: Reads rows from accounts, clients, and broker_accounts.


First returned row — client_count: 45.00.

For exactly the ordinary CT user accounts opted in...

System: CT

accounts

System: CT

client

SELECT COUNT(DISTINCT user_id) AS client_count, NULL AS email FROM ct.client_360 WHERE NOT user_id IS NULL

For exactly the ordinary CT user accounts opted in to marketing emails whose registration is still incomplete in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.

Calculates how many DISTINCT user_id there are.

Summary: Works out how many DISTINCT user_id there are from client_360.


For exactly the CT accounts of any role whose earl...

System: CT

CT accounts

System: CT

broker

System: CT

registration date

System: CT

client

SELECT COUNT(DISTINCT a.id)::int AS client_count FROM public.accounts a JOIN public.clients c ON c.user_id = a.id JOIN public.broker_accounts ba ON ba.user_id = a.id WHERE c.completed_registration_at IS NOT NULL AND ba.verified_at IS NOT NULL AND ba.deleted_at IS NULL AND NOT EXISTS (SELECT 1 FROM public.broker_accounts b2 WHERE b2.user_id = a.id AND b2.deleted_at IS NULL AND b2.verified_at IS NOT NULL AND b2.verified_at <= c.completed_registration_at) GROUP BY ()

SELECT
  CAST(COUNT(DISTINCT a.id) AS INT) AS client_count
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
JOIN public.broker_accounts AS ba
  ON ba.user_id = a.id
WHERE
  NOT c.completed_registration_at IS NULL
  AND NOT ba.verified_at IS NULL
  AND ba.deleted_at IS NULL
  AND NOT EXISTS(
    SELECT
      1
    FROM public.broker_accounts AS b2
    WHERE
      b2.user_id = a.id
      AND b2.deleted_at IS NULL
      AND NOT b2.verified_at IS NULL
      AND b2.verified_at <= c.completed_registration_at
  )
GROUP BY
  ()

For exactly the CT accounts of any role whose earliest verified broker account date is after their completed registration date in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.

Calculates how many DISTINCT a.id there are.

Keeps only rows matching filters on deleted_at, completed_registration_at, verified_at, user_id, and id.

Summary: Works out how many DISTINCT a.id there are from accounts, clients, and broker_accounts grouped by ().


Show the same checked IDs for the ordinary CT user...

System: CT

accounts

System: CT

0 matching rows — a filter likely did not bind; verify filters. High confidence (100%) — simple query

SELECT DISTINCT a.user_id, NULL AS email FROM ct.accounts AS a WHERE a.client_type = 'individual' AND NOT a.client_status IN ('complete', 'completed', 'active') ORDER BY 1 DESC NULLS LAST LIMIT 10000

Show the same checked IDs for the ordinary CT user accounts opted in to marketing emails whose registration is still incomplete from the first result, this time in descending user_id order. Keep every member and show only user_id.


Show the same checked IDs for the CT accounts of a...

System: CT

CT accounts

System: CT

broker

System: CT

registration date

System: CT

0 matching rows — a filter likely did not bind; verify filters. High confidence (85%) — moderate complexity

SELECT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE NOT c.completed_registration_at IS NULL AND EXISTS(SELECT 1 FROM public.broker_accounts AS ba WHERE ba.user_id = a.id AND NOT ba.verified_at IS NULL) AND (SELECT MIN(ba2.verified_at) FROM public.broker_accounts AS ba2 WHERE ba2.user_id = a.id AND NOT ba2.verified_at IS NULL) > c.completed_registration_at ORDER BY a.id DESC NULLS LAST

SELECT
  a.id AS user_id
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT c.completed_registration_at IS NULL
  AND EXISTS(
    SELECT
      1
    FROM public.broker_accounts AS ba
    WHERE
      ba.user_id = a.id AND NOT ba.verified_at IS NULL
  )
  AND (
    SELECT
      MIN(ba2.verified_at)
    FROM public.broker_accounts AS ba2
    WHERE
      ba2.user_id = a.id AND NOT ba2.verified_at IS NULL
  ) > c.completed_registration_at
ORDER BY
  a.id DESC NULLS LAST

Show the same checked IDs for the CT accounts of any role whose earliest verified broker account date is after their completed registration date from the first result, this time in descending user_id order. Keep every member and show only user_id.


Keep the ordinary CT user accounts opted in to mar...

System: CT

accounts

System: CT

client

SELECT COUNT(DISTINCT a.user_id) AS client_count, NULL AS email FROM ct.accounts AS a WHERE a.client_type = 'individual' AND NOT a.client_status IN ('complete', 'completed', 'active')

Keep the ordinary CT user accounts opted in to marketing emails whose registration is still incomplete membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.

Calculates how many DISTINCT a.user_id there are.

Keeps only rows matching filters on client_type and client_status.

Summary: Works out how many DISTINCT a.user_id there are from accounts.


Keep the CT accounts of any role whose earliest ve...

System: CT

CT accounts

System: CT

broker

System: CT

registration date

System: CT

client

SELECT COUNT(DISTINCT t.user_id) AS client_count FROM (SELECT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE NOT c.completed_registration_at IS NULL AND EXISTS(SELECT 1 FROM public.broker_accounts AS ba WHERE ba.user_id = a.id AND NOT ba.verified_at IS NULL) AND (SELECT MIN(ba2.verified_at) FROM public.broker_accounts AS ba2 WHERE ba2.user_id = a.id AND NOT ba2.verified_at IS NULL) > c.completed_registration_at) AS t

SELECT
  COUNT(DISTINCT t.user_id) AS client_count
FROM (
  SELECT
    a.id AS user_id
  FROM public.accounts AS a
  JOIN public.clients AS c
    ON c.user_id = a.id
  WHERE
    NOT c.completed_registration_at IS NULL
    AND EXISTS(
      SELECT
        1
      FROM public.broker_accounts AS ba
      WHERE
        ba.user_id = a.id AND NOT ba.verified_at IS NULL
    )
    AND (
      SELECT
        MIN(ba2.verified_at)
      FROM public.broker_accounts AS ba2
      WHERE
        ba2.user_id = a.id AND NOT ba2.verified_at IS NULL
    ) > c.completed_registration_at
) AS t

Keep the CT accounts of any role whose earliest verified broker account date is after their completed registration date membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.

Calculates how many DISTINCT t.user_id there are.

Summary: Works out how many DISTINCT t.user_id there are from accounts, clients, and broker_accounts.


System: CT

CT accounts

System: CT

broker

System: CT

System: PD

person ID

churn-tier-definitions trade-existence-default-booked settlement-is-ct-trade-lifecycle activation-definition-gold trade-existence-gold-booked

```json
{
  "sql": "",
  "explanation": "The request requires broker-account verification state (broker_accounts.verified_at / a current 'outdated' marker), which exists only in raw ct tables that the federation rule forbids me from referencing (only ct.client_360 and pipedrive.* allowed), and no ta

List every distinct CT accounts of any role with a previously verified broker account now marked outdated. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.


System: CT

CT accounts

System: CT

broker

System: CT

System: PD

person ID

SELECT DISTINCT a.id AS user_id FROM public.accounts AS a WHERE EXISTS(SELECT 1 FROM public.broker_accounts AS ba WHERE ba.user_id = a.id AND NOT ba.notified_at IS NULL AND ba.deleted_at IS NULL) AND NOT EXISTS(SELECT 1 FROM public.broker_accounts AS ba2 WHERE ba2.user_id = a.id AND NOT ba2.verified_at IS NULL) ORDER BY 1 LIMIT 10000

SELECT DISTINCT ba.user_id AS user_id FROM public.broker_accounts AS ba WHERE NOT ba.user_id IS NULL AND NOT ba.notified_at IS NULL AND ba.deleted_at IS NULL AND NOT EXISTS(SELECT 1 FROM public.broker_accounts AS v WHERE v.user_id = ba.user_id AND NOT v.verified_at IS NULL AND v.deleted_at IS NULL) ORDER BY 1 LIMIT 10000

```json
{
  "sql": "",
  "explanation": "The gold catalog contains no broker-account relation or verified/notified flags in ct.client_360, so the broker-account cohort predicate cannot be expressed in the allowed schema.",
  "confidence": "uncertain",
  "warnings": ["public.broker_accounts is not in

List every distinct CT accounts of any role with a notified broker account but no broker account that has ever been verified. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.


System: CT

CT accounts

System: CT

broker

System: CT

client

```json
{
  "sql": "",
  "explanation": "Cannot generate: the request depends on an undefined 'first checked result' cohort and tables (ct.client_360, pipedrive.*, broker-account verification state) not present in the provided schema.",
  "confidence": "uncertain",
  "warnings": ["Referenced federat

For exactly the CT accounts of any role with a previously verified broker account now marked outdated in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


System: CT

CT accounts

System: CT

broker

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a WHERE EXISTS (SELECT 1 FROM public.broker_accounts ba1 WHERE ba1.user_id = a.id AND ba1.deleted_at IS NULL AND ba1.notified_at IS NOT NULL) AND NOT EXISTS (SELECT 1 FROM public.broker_accounts ba2 WHERE ba2.user_id = a.id AND ba2.deleted_at IS NULL AND ba2.verified_at IS NOT NULL)

SELECT COUNT(DISTINCT ba.user_id) AS client_count FROM public.broker_accounts ba WHERE ba.notified_at IS NOT NULL AND ba.deleted_at IS NULL AND NOT EXISTS (SELECT 1 FROM public.broker_accounts v WHERE v.user_id = ba.user_id AND v.verified_at IS NOT NULL)

```json
{
  "sql": "",
  "explanation": "The gold catalog contains no broker-account table or broker account notified/verified columns, so this predicate cannot be evaluated from the allowed relations.",
  "confidence": "uncertain",
  "warnings": ["public.broker_accounts is not in the gold allowlist

For exactly the CT accounts of any role with a notified broker account but no broker account that has ever been verified in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


System: CT

CT accounts

System: CT

broker

System: CT

```json
{
  "sql": "",
  "explanation": "This request refers to 'the first result' and 'same checked IDs' from a prior query that was not provided, and the referenced curated tables (ct.client_360) are not present in the available schema, so the cohort cannot be reconstructed.",
  "confidence": "unc

Show the same checked IDs for the CT accounts of any role with a notified broker account but no broker account that has ever been verified from the first result, this time in descending user_id order. Keep every member and show only user_id.


System: CT

CT accounts

System: CT

broker

System: CT

client

```json
{
  "sql": "",
  "explanation": "The request depends on a prior ('third') result set and tables (ct.client_360, pipedrive.*) that are not present in the provided schema, so no valid single SELECT can be generated.",
  "confidence": "uncertain",
  "warnings": [
    "Referenced views ct.client

Keep the CT accounts of any role with a notified broker account but no broker account that has ever been verified membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


System: CT

CT accounts

System: CT

broker

System: CT

High confidence (85%) — implicit time period, simple query

SELECT c.user_id FROM ct.client_360 AS c GROUP BY 1 ORDER BY 1 DESC NULLS LAST LIMIT 10001

SELECT a.id AS user_id FROM public.accounts AS a JOIN public.broker_accounts AS ba ON ba.user_id = a.id WHERE NOT ba.verified_at IS NULL AND LOWER(ba.status) = 'outdated' ORDER BY 1 DESC NULLS LAST LIMIT 10001

Show the same checked IDs for the CT accounts of any role with a previously verified broker account now marked outdated from the first result, this time in descending user_id order. Keep every member and show only user_id.

Gold / Pipedrive: Reads from client_360.

CT Ledger: Reads from accounts and broker_accounts.

CT Ledger: Keeps only rows matching filters on verified_at and status.

Summary: Combines the source results. Gold / Pipedrive: Reads rows from client_360 grouped by user_id. CT Ledger: Reads rows from accounts and broker_accounts.


System: CT

CT accounts

System: CT

brokers

System: CT

System: PD

person ID

SELECT a.id AS user_id FROM public.accounts a JOIN public.broker_accounts ba ON ba.user_id = a.id WHERE ba.verified_at IS NOT NULL AND ba.deleted_at IS NULL GROUP BY a.id HAVING COUNT(DISTINCT ba.broker_id) >= 2 ORDER BY 1

SELECT ba.user_id AS user_id, COUNT(DISTINCT ba.broker_id) AS verified_broker_count FROM public.broker_accounts ba WHERE ba.deleted_at IS NULL AND ba.verified_at IS NOT NULL AND ba.user_id IS NOT NULL GROUP BY 1 HAVING COUNT(DISTINCT ba.broker_id) >= 2 ORDER BY 1 ASC

```json
{
  "sql": "",
  "explanation": "The gold catalog contains no broker or broker-account relation, so verified-broker multiplicity cannot be computed from any allowed table (ct.client_360's column list is also unavailable to confirm a broker count).",
  "confidence": "uncertain",
  "warnings":

List every distinct CT accounts of any role that have at least two different verified brokers. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.


System: CT

CT accounts

System: CT

brokers

System: CT

client

```json
{
  "sql": "",
  "explanation": "The request requires ct.client_360 and pipedrive.* tables, which are not present in the provided schema, and the question itself is ambiguous, so no safe SELECT can be generated.",
  "confidence": "uncertain",
  "warnings": [
    "The mandated federation gold

For exactly the CT accounts of any role that have at least two different verified brokers in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


System: CT

CT accounts

System: CT

broker

System: CT

client

SELECT COUNT(DISTINCT ba.user_id) AS client_count FROM public.broker_accounts ba WHERE ba.user_id IS NOT NULL AND ba.verified_at IS NOT NULL AND ba.deleted_at IS NULL AND lower(ba.status) = 'outdated'

SELECT COUNT(DISTINCT ba.user_id) AS client_count FROM public.broker_accounts ba WHERE ba.verified_at IS NOT NULL AND ba.status = 'outdated' AND ba.deleted_at IS NULL

Keep the CT accounts of any role with a previously verified broker account now marked outdated membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


System: CT

CT accounts

System: CT

brokers

System: CT

```json
{
  "sql": "",
  "explanation": "The request depends on an unspecified 'first result' and requires ct.client_360 / pipedrive tables that are not present in the provided schema, so no SQL can be generated.",
  "confidence": "uncertain",
  "warnings": [
    "Referenced gold tables (ct.client_3

Show the same checked IDs for the CT accounts of any role that have at least two different verified brokers from the first result, this time in descending user_id order. Keep every member and show only user_id.


System: CT

CT accounts

System: CT

brokers

System: CT

client

```json
{
  "sql": "",
  "explanation": "This request depends on a prior result ('the third result') which is unavailable here, and mandates tables (ct.client_360, pipedrive.*) that are not in the provided schema.",
  "confidence": "uncertain",
  "warnings": [
    "Referencing a previous multi-step

Keep the CT accounts of any role that have at least two different verified brokers membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


List every distinct corporate CT client records wi...

System: CT

client

System: CT

System: PD

person ID

SELECT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE NOT c.type IS NULL AND c.type <> 'PersonalAccount' AND NOT c.completed_registration_at IS NULL AND NOT EXISTS(SELECT 1 FROM public.trade_bookings AS tb WHERE tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed') GROUP BY a.id ORDER BY 1 ASC LIMIT 10000

SELECT
  a.id AS user_id
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT c.type IS NULL
  AND c.type <> 'PersonalAccount'
  AND NOT c.completed_registration_at IS NULL
  AND NOT EXISTS(
    SELECT
      1
    FROM public.trade_bookings AS tb
    WHERE
      tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed'
  )
GROUP BY
  a.id
ORDER BY
  1 ASC
LIMIT 10000

activation-definition activation-definition-gold onboarding-duration churn-tier-definitions declared-currency-intent client-type-sti-classes trade-existence-gold-booked

List every distinct corporate CT client records with completed registration who have no non-deleted, non-closed booking. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.

Reads from accounts, clients, and trade_bookings.

Keeps only rows matching filters on type, completed_registration_at, status, user_id, id, and deleted_at.

Summary: Reads rows from accounts, clients, and trade_bookings grouped by id.


System: CT

client

System: CT

System: PD

person ID

SELECT DISTINCT c.user_id AS user_id FROM public.clients AS c WHERE c.type = 'PersonalAccount' AND NOT c.sell_currencies IS NULL AND ARRAY_LENGTH(c.sell_currencies, 1) > 0 AND NOT c.buy_currencies IS NULL AND ARRAY_LENGTH(c.buy_currencies, 1) > 0 ORDER BY 1 LIMIT 10000

SELECT COALESCE(c.user_id, p.id) AS user_id FROM ct.client_360 AS c LEFT JOIN pipedrive.persons_enriched AS p ON p.user_id = c.user_id WHERE c.type = 'private' AND COALESCE(c.sell_currencies, '{}') <> '{}' AND COALESCE(c.buy_currencies, '{}') <> '{}' GROUP BY 1 ORDER BY 1 LIMIT 10000

List every distinct private CT client records who declared at least one currency on both the sell and buy sides. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.

The query refers to a table or column unavailable on the selected connection.


For exactly the corporate CT client records with c...

System: CT

client

Query complexity

Complex query: 1 JOINs, subqueries, CTEs,

WITH eligible AS (SELECT a.id FROM public.accounts a JOIN public.clients c ON c.user_id = a.id WHERE c.completed_registration_at IS NOT NULL AND c.type IS NOT NULL AND c.type <> 'PersonalAccount' AND NOT EXISTS (SELECT 1 FROM public.trade_bookings tb WHERE tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed')) SELECT COUNT(*) AS client_count FROM eligible

WITH eligible AS (
  SELECT
    a.id
  FROM public.accounts AS a
  JOIN public.clients AS c
    ON c.user_id = a.id
  WHERE
    NOT c.completed_registration_at IS NULL
    AND NOT c.type IS NULL
    AND c.type <> 'PersonalAccount'
    AND NOT EXISTS(
      SELECT
        1
      FROM public.trade_bookings AS tb
      WHERE
        tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed'
    )
)
SELECT
  COUNT(*) AS client_count
FROM eligible

For exactly the corporate CT client records with completed registration who have no non-deleted, non-closed booking in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.

Reads from eligible, accounts, clients, and trade_bookings.

Summary: Works out how many rows there are from eligible, accounts, clients, and trade_bookings.


System: CT

client

```json
{
  "sql": "",
  "explanation": "The request requires ct.client_360 and pipedrive.* tables, which are not present in the provided schema (only public.* tables are available), so I cannot generate a compliant query.",
  "confidence": "uncertain",
  "warnings": [
    "Federation gold-leg requi

For exactly the private CT client records who declared at least one currency on both the sell and buy sides in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


System: CT

client

System: CT

SELECT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE c.type = 'PersonalAccount' AND COALESCE(ARRAY_LENGTH(c.sell_currencies, 1), 0) >= 1 AND COALESCE(ARRAY_LENGTH(c.buy_currencies, 1), 0) >= 1 ORDER BY 1 DESC NULLS LAST LIMIT 10000

SELECT user_id FROM public.clients WHERE type = 'personal' AND NOT sell_currencies IS NULL AND sell_currencies <> '{}' AND NOT buy_currencies IS NULL AND buy_currencies <> '{}' ORDER BY user_id DESC NULLS LAST LIMIT 10000

Show the same checked IDs for the private CT client records who declared at least one currency on both the sell and buy sides from the first result, this time in descending user_id order. Keep every member and show only user_id.


Show the same checked IDs for the corporate CT cli...

System: CT

client

System: CT

SELECT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE NOT c.type IS NULL AND c.type <> 'PersonalAccount' AND NOT c.completed_registration_at IS NULL AND NOT EXISTS(SELECT 1 FROM public.trade_bookings AS tb WHERE tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed') ORDER BY a.id DESC NULLS LAST LIMIT 10000

SELECT
  a.id AS user_id
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT c.type IS NULL
  AND c.type <> 'PersonalAccount'
  AND NOT c.completed_registration_at IS NULL
  AND NOT EXISTS(
    SELECT
      1
    FROM public.trade_bookings AS tb
    WHERE
      tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed'
  )
ORDER BY
  a.id DESC NULLS LAST
LIMIT 10000

Show the same checked IDs for the corporate CT client records with completed registration who have no non-deleted, non-closed booking from the first result, this time in descending user_id order. Keep every member and show only user_id.

Summary: Reads rows from accounts, clients, and trade_bookings.


System: CT

client

```json
{
  "sql": "",
  "explanation": "The question depends on a prior ('third') result set and a ct.client_360 / pipedrive schema that is not provided in the available schema, so a safe SQL query cannot be constructed.",
  "confidence": "uncertain",
  "warnings": [
    "ct.client_360 and pipedriv

Keep the private CT client records who declared at least one currency on both the sell and buy sides membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


Keep the corporate CT client records with complete...

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.clients c ON c.user_id = a.id WHERE c.completed_registration_at IS NOT NULL AND c.type IS NOT NULL AND c.type <> 'PersonalAccount' AND NOT EXISTS (SELECT 1 FROM public.trade_bookings tb WHERE tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed')

SELECT
  COUNT(DISTINCT a.id) AS client_count
FROM public.accounts AS a
JOIN public.clients AS c
  ON c.user_id = a.id
WHERE
  NOT c.completed_registration_at IS NULL
  AND NOT c.type IS NULL
  AND c.type <> 'PersonalAccount'
  AND NOT EXISTS(
    SELECT
      1
    FROM public.trade_bookings AS tb
    WHERE
      tb.user_id = a.id AND tb.deleted_at IS NULL AND tb.status <> 'closed'
  )

Keep the corporate CT client records with completed registration who have no non-deleted, non-closed booking membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.

Summary: Works out how many DISTINCT a.id there are from accounts, clients, and trade_bookings.


System: CT

client

System: CT

client type

System: CT

broker

System: CT

System: PD

person ID

SELECT DISTINCT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE (c.type IS NULL OR TRIM(c.type) = '') AND EXISTS(SELECT 1 FROM public.broker_accounts AS ba WHERE ba.user_id = a.id AND ba.deleted_at IS NULL) ORDER BY 1 LIMIT 10000

SELECT c.user_id FROM ct.client_360 AS c WHERE (c.type IS NULL OR c.type = '' OR c.type = 'unknown') AND EXISTS(SELECT 1 FROM public.broker_accounts AS b WHERE b.user_id = c.user_id AND b.deleted_at IS NULL) GROUP BY c.user_id ORDER BY c.user_id ASC LIMIT 10000

List every distinct CT client records whose client type is unknown and who have at least one broker account. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.


45 rows returned. Only the first 12 returned rows are available for this summary.

List every distinct CT accounts of any role that h...

System: CT

CT accounts

Quote-level rows with DIRECT user_id (= accounts.id). No account_id column. type is by_client/admin_ping/rate_alert/rsi_alert — a quote a user MADE = type 'by_client' only (rate-alert/RSI/admin pings are system rows, ~40% of the table). status booked/pending; a booked quote converted to a trade (trade_bookings.quote_id = quotes.id).

System: CT

quotes

System: CT

System: PD

person ID

SELECT c.user_id FROM ct.client_360 AS c GROUP BY 1 ORDER BY 1 ASC LIMIT 10001

SELECT a.id AS user_id FROM public.accounts AS a WHERE EXISTS(SELECT 1 FROM public.quotes AS q WHERE q.user_id = a.id AND q.type <> 'by_client') AND NOT EXISTS(SELECT 1 FROM public.quotes AS q2 WHERE q2.user_id = a.id AND q2.type = 'by_client') ORDER BY 1 LIMIT 10001

List every distinct CT accounts of any role that have system-generated quotes and no user-requested quote. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.

CT Ledger: Reads from accounts and quotes.

CT Ledger: Keeps only rows matching filters on user_id, id, and type.

Summary: Combines the source results. Gold / Pipedrive: Reads rows from client_360 grouped by user_id. CT Ledger: Reads rows from accounts and quotes.


System: CT

client

System: CT

client type

System: CT

broker

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.clients c ON c.user_id = a.id WHERE c.type IS NULL AND EXISTS (SELECT 1 FROM public.broker_accounts ba WHERE ba.user_id = a.id AND ba.deleted_at IS NULL)

SELECT c.user_id, COUNT(DISTINCT c.user_id) OVER () AS client_count FROM public.clients c WHERE (c.type IS NULL OR c.type = '' OR c.type = 'unknown') AND c.user_id IS NOT NULL AND EXISTS (SELECT 1 FROM public.broker_accounts ba WHERE ba.user_id = c.user_id) GROUP BY c.user_id

For exactly the CT client records whose client type is unknown and who have at least one broker account in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


System: CT

CT accounts

System: CT

quotes

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a WHERE EXISTS (SELECT 1 FROM public.quotes q WHERE q.user_id = a.id AND q.type <> 'by_client') AND NOT EXISTS (SELECT 1 FROM public.quotes q2 WHERE q2.user_id = a.id AND q2.type = 'by_client')

SELECT quotes.user_id AS user_id, COUNT(*) FILTER(WHERE quotes.type = 'by_client') AS quote_count FROM public.quotes WHERE NOT quotes.user_id IS NULL GROUP BY quotes.user_id HAVING COUNT(*) FILTER(WHERE quotes.type = 'by_client') = 0 AND COUNT(*) FILTER(WHERE quotes.type <> 'by_client' OR quotes.type IS NULL) > 0 ORDER BY 1

For exactly the CT accounts of any role that have system-generated quotes and no user-requested quote in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


Show the same checked IDs for the CT client record...

System: CT

client

System: CT

client type

System: CT

broker

System: CT

SELECT c.user_id FROM ct.client_360 AS c WHERE COALESCE(c.client_type, '') = '' AND EXISTS(SELECT 1 FROM ct.accounts AS a WHERE a.user_id = c.user_id) GROUP BY 1 ORDER BY 1 DESC NULLS LAST LIMIT 10001

SELECT a.id AS user_id FROM public.accounts AS a JOIN public.clients AS c ON c.user_id = a.id WHERE (c.type IS NULL OR TRIM(c.type) = '') AND EXISTS(SELECT 1 FROM public.broker_accounts AS ba WHERE ba.user_id = a.id) ORDER BY a.id DESC NULLS LAST LIMIT 10001

Show the same checked IDs for the CT client records whose client type is unknown and who have at least one broker account from the first result, this time in descending user_id order. Keep every member and show only user_id.

Gold / Pipedrive: Reads from client_360 and accounts.

Gold / Pipedrive: Keeps only rows matching filters on client_type and user_id.

Gold / Pipedrive: Groups the results by user_id.

CT Ledger: Reads from accounts, clients, and broker_accounts.

CT Ledger: Keeps only rows matching filters on type, user_id, and id.

Summary: Combines the source results. Gold / Pipedrive: Reads rows from client_360 and accounts grouped by user_id. CT Ledger: Reads rows from accounts, clients, and broker_accounts.


System: CT

CT accounts

System: CT

quotes

System: CT

SELECT user_id FROM ct.client_360 GROUP BY user_id ORDER BY user_id DESC NULLS LAST LIMIT 10001

SELECT a.id AS user_id FROM public.accounts AS a WHERE EXISTS(SELECT 1 FROM public.quotes AS q WHERE q.user_id = a.id AND q.type <> 'by_client') AND NOT EXISTS(SELECT 1 FROM public.quotes AS q2 WHERE q2.user_id = a.id AND q2.type = 'by_client') ORDER BY 1 DESC NULLS LAST LIMIT 10001

Show the same checked IDs for the CT accounts of any role that have system-generated quotes and no user-requested quote from the first result, this time in descending user_id order. Keep every member and show only user_id.


System: CT

client

System: CT

client type

System: CT

broker

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a JOIN public.clients c ON c.user_id = a.id WHERE c.type IS NULL AND EXISTS (SELECT 1 FROM public.broker_accounts ba WHERE ba.user_id = a.id)

SELECT user_id, COUNT(DISTINCT user_id) OVER () AS client_count FROM ct.client_360 WHERE (client_type IS NULL OR client_type = 'unknown') AND COALESCE(broker_accounts_count, 0) >= 1 GROUP BY user_id ORDER BY user_id DESC NULLS LAST

Keep the CT client records whose client type is unknown and who have at least one broker account membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


System: CT

CT accounts

System: CT

quotes

System: CT

client

SELECT COUNT(DISTINCT a.id) AS client_count FROM public.accounts a WHERE a.deleted_at IS NULL AND EXISTS (SELECT 1 FROM public.quotes q WHERE q.user_id = a.id AND q.type <> 'by_client') AND NOT EXISTS (SELECT 1 FROM public.quotes q2 WHERE q2.user_id = a.id AND q2.type = 'by_client')

SELECT COUNT(DISTINCT q.user_id) AS client_count FROM public.quotes q JOIN public.accounts a ON a.id = q.user_id WHERE q.type <> 'by_client' AND q.user_id NOT IN (SELECT user_id FROM public.quotes WHERE type = 'by_client' AND user_id IS NOT NULL)

Keep the CT accounts of any role that have system-generated quotes and no user-requested quote membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


System: CT

CT accounts

System: CT

quote

System: CT

quote ID

System: CT

System: PD

person ID

SELECT c.user_id FROM ct.client_360 AS c GROUP BY 1 ORDER BY 1 LIMIT 10001

SELECT DISTINCT q.user_id FROM public.quotes AS q JOIN public.trade_bookings AS tb ON tb.quote_id = q.id WHERE tb.deleted_at IS NULL AND tb.status <> 'closed' AND NOT q.user_id IS NULL ORDER BY 1 LIMIT 10001

List every distinct CT accounts of any role whose own quote converted to a non-deleted, non-closed booking through the quote ID link. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.

CT Ledger: Reads from quotes and trade_bookings.

CT Ledger: Keeps only rows matching filters on deleted_at, status, and user_id.

Summary: Combines the source results. Gold / Pipedrive: Reads rows from client_360 grouped by user_id. CT Ledger: Reads rows from quotes and trade_bookings.


System: CT

CT accounts

System: CT

quote

System: CT

broker

System: CT

System: PD

person ID

```json
{
  "sql": "",
  "explanation": "The request requires ct.client_360 and pipedrive.* tables plus a broker verification timestamp field, none of which are present in the provided schema, so no valid query can be generated.",
  "confidence": "uncertain",
  "warnings": [
    "Schema contains no

List every distinct CT accounts of any role whose user-requested quote predates their earliest known broker verification timestamp. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.


System: CT

CT accounts

System: CT

quote

System: CT

broker

System: CT

client

```json
{
  "sql": "",
  "explanation": "The federation gold leg mandates drawing fields only from ct.client_360 (and pipedrive.*), but ct.client_360 does not exist in the provided schema, so no compliant query can be generated.",
  "confidence": "uncertain",
  "warnings": ["ct.client_360 is not in

For exactly the CT accounts of any role whose user-requested quote predates their earliest known broker verification timestamp in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


For exactly the CT accounts of any role whose own ...

System: CT

CT accounts

System: CT

quote

System: CT

quote ID

System: CT

client

SELECT user_id FROM ct.client_360 GROUP BY 1 ORDER BY 1 LIMIT 10001

SELECT a.id AS user_id FROM public.accounts AS a WHERE EXISTS(SELECT 1 FROM public.quotes AS q JOIN public.trade_bookings AS tb ON tb.quote_id = q.id WHERE q.user_id = a.id AND q.type = 'by_client' AND EXISTS(SELECT 1 FROM public.trade_bookings AS __qb WHERE __qb.quote_id = q.id AND __qb.status <> 'closed' AND __qb.deleted_at IS NULL) AND tb.deleted_at IS NULL AND tb.status <> 'closed') ORDER BY 1 LIMIT 10001

For exactly the CT accounts of any role whose own quote converted to a non-deleted, non-closed booking through the quote ID link in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.

CT Ledger: Reads from accounts, quotes, and trade_bookings.

CT Ledger: Keeps only rows matching filters on quote_id, id, status, deleted_at, user_id, and type.

Summary: Combines the source results. Gold / Pipedrive: Reads rows from client_360 grouped by user_id. CT Ledger: Reads rows from accounts, quotes, and trade_bookings.


System: CT

CT accounts

System: CT

quote

System: CT

broker

System: CT

Show the same checked IDs for the CT accounts of any role whose user-requested quote predates their earliest known broker verification timestamp from the first result, this time in descending user_id order. Keep every member and show only user_id.


System: CT

CT accounts

System: CT

quote

System: CT

quote ID

System: CT

SELECT DISTINCT q.user_id FROM public.quotes AS q JOIN public.trade_bookings AS tb ON tb.quote_id = q.id WHERE tb.deleted_at IS NULL AND tb.status <> 'closed' ORDER BY 1 DESC NULLS LAST LIMIT 10000

Show the same checked IDs for the CT accounts of any role whose own quote converted to a non-deleted, non-closed booking through the quote ID link from the first result, this time in descending user_id order. Keep every member and show only user_id.


System: CT

CT accounts

System: CT

quote

System: CT

broker

System: CT

client

```json
{
  "sql": "",
  "explanation": "The requested 'federation gold leg' requires ct.client_360 and pipedrive.* tables, which are not present in the provided schema, and the question depends on an unspecified 'third result' — I cannot generate a reliable SELECT.",
  "confidence": "uncertain",

Keep the CT accounts of any role whose user-requested quote predates their earliest known broker verification timestamp membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


System: CT

CT accounts

System: CT

quote

System: CT

quote ID

System: CT

client

SELECT COUNT(DISTINCT q.user_id) AS client_count FROM public.quotes AS q JOIN public.trade_bookings AS tb ON tb.quote_id = q.id WHERE (q.type = 'by_client' AND NOT q.user_id IS NULL AND tb.deleted_at IS NULL AND tb.status <> 'closed') AND NOT q.user_id IN (SELECT id FROM public.accounts WHERE id = 1 OR email ILIKE '%@currencytransfer.com')

SELECT user_id, COUNT(DISTINCT CASE WHEN b.deleted_at IS NULL AND b.status <> 'closed' THEN b.id END) AS client_count FROM (SELECT id AS user_id FROM public.accounts WHERE deleted_at IS NULL) AS a JOIN public.quotes AS q ON q.user_id = a.user_id AND q.type = 'by_client' JOIN public.trade_bookings AS b ON b.quote_id = q.id AND b.deleted_at IS NULL AND b.status <> 'closed' GROUP BY 1

Keep the CT accounts of any role whose own quote converted to a non-deleted, non-closed booking through the quote ID link membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.


System: CT

CT accounts

System: CT

System: PD

person ID

SELECT a.id AS user_id FROM public.accounts AS a WHERE EXISTS(SELECT 1 FROM public.trade_bookings AS tb WHERE tb.user_id = a.id AND tb.deleted_at IS NULL) AND NOT EXISTS(SELECT 1 FROM public.trade_bookings AS tb2 WHERE tb2.user_id = a.id AND tb2.deleted_at IS NULL AND tb2.status = 'settled') ORDER BY 1 ASC LIMIT 10000

SELECT tb.user_id, COUNT(*) FILTER(WHERE tb.deleted_at IS NULL) AS trade_count FROM public.trade_bookings AS tb WHERE tb.deleted_at IS NULL AND NOT tb.user_id IS NULL GROUP BY tb.user_id HAVING COUNT(*) FILTER(WHERE tb.deleted_at IS NULL) > 0 AND COUNT(*) FILTER(WHERE NOT tb.settlement_at IS NULL) = 0 ORDER BY tb.user_id ASC

List every distinct CT accounts of any role with a non-deleted booking but no settled booking. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.


System: CT

CT accounts

System: CT

client

```json
{
  "sql": "",
  "explanation": "The request requires the table ct.client_360 (per federation constraints) and a prior 'first checked result', neither of which is available in the provided schema, so no valid query can be generated.",
  "confidence": "uncertain",
  "warnings": ["ct.client_36

For exactly the CT accounts of any role with a non-deleted booking but no settled booking in the first checked result, return their distinct count as client_count. Keep that membership and return zero if it is empty.


List every distinct CT accounts of any role with a...

System: CT

CT accounts

System: CT

System: PD

person ID

SELECT user_id FROM ct.client_360 GROUP BY user_id HAVING COUNT(*) > 0 LIMIT 10001

SELECT DISTINCT tb.user_id FROM public.trade_bookings AS tb WHERE NOT tb.invoice_at IS NULL AND NOT tb.status IN ('closed', 'settled') ORDER BY 1 LIMIT 10001

List every distinct CT accounts of any role with an invoiced booking record that is neither closed nor settled, including records marked deleted. Return only user_id, in ascending order; use the person ID for a Pipedrive-only person.

Gold / Pipedrive: Reads from client_360.

CT Ledger: Keeps only rows matching filters on invoice_at and status.

Summary: Combines the source results. Gold / Pipedrive: Reads rows from client_360 grouped by user_id. CT Ledger: Reads rows from trade_bookings.


System: CT

CT accounts

System: CT

```json
{
  "sql": "",
  "explanation": "The question depends on a prior result ('checked IDs from the first result') and on ct.client_360, whose column list is not provided, so I cannot confidently map 'non-deleted booking but no settled booking' to known columns.",
  "confidence": "uncertain",
  "

Show the same checked IDs for the CT accounts of any role with a non-deleted booking but no settled booking from the first result, this time in descending user_id order. Keep every member and show only user_id.


System: CT

CT accounts

System: CT

client

```json
{
  "sql": "",
  "explanation": "The request depends on an unspecified prior 'third result' and tables (ct.client_360, pipedrive.*) that are not present in the provided schema, so no valid single SELECT can be generated.",
  "confidence": "uncertain",
  "warnings": ["References a prior inter

Keep the CT accounts of any role with a non-deleted booking but no settled booking membership from the third result and count those distinct IDs as client_count. An empty result counts as zero.