Prompt Library / Data Science

Natural Language to BigQuery SQL

Turns a plain-English question into BigQuery SQL.

InternalGenAISelf-service analytics · by Arjun Nair · v1.9
★ 4.6 2.4K runsUpdated 2026-07-28

Prompt template

2 variables
Write a BigQuery Standard SQL query that answers the question below, using only the tables and columns listed. Query the gold layer of the lakehouse. Never select customer identifiers or names; aggregate to at least 10 customers per group.

Question: {question}
Available tables:
{schema}

Return the SQL, then one sentence explaining what it does.
{question}{schema}

Playground

Simulated sandbox

Ownership and sensitivity

Owned by

Group Data & AIData Science

Accountable owner: Arjun Nair

Who approves access

No approval needed. Self-service: subscribe and use, logged for chargeback.

Internal

Open to all staff. Aggregates, policy text, public series and synthetic data.

Self-service: subscribe and use, logged for chargeback.

GenAI
Generates text; prompt screening for customer data and output review apply.

Example input & output

Example input

{question}
How many ETB customers in each segment converted to a second product in the last 90 days?
{schema}
`abmb-lakehouse.gold.customer_360` (customer_token, segment, product_count, first_product_date, etb_flag); `abmb-lakehouse.gold.product_openings` (customer_token, product_code, opened_date)

Example output

SELECT c.segment, COUNT(DISTINCT c.customer_token) AS converted_customers FROM `abmb-lakehouse.gold.customer_360` AS c JOIN `abmb-lakehouse.gold.product_openings` AS o ON o.customer_token = c.customer_token WHERE c.etb_flag = TRUE AND o.opened_date >= DATE_SUB(CURRENT_DATE('Asia/Kuala_Lumpur'), INTERVAL 90 DAY) AND o.opened_date > c.first_product_date GROUP BY c.segment HAVING converted_customers >= 10 ORDER BY converted_customers DESC; Counts existing-to-bank customers per segment who opened another product in the last 90 days, suppressing groups under 10.

Details

Author
Arjun Nair
Version
v1.9
Rating
★ 4.6
Runs
2.4K
Licence
Group Reuse
Updated
2026-07-28

Powered by

policy-rag-copilot →

This template is tuned for the target model above. Forked copies keep the same target model binding until republished.

Community · 0 threads

Questions, findings and requests from the business units that use this asset. Owners reply here; threads with upvotes surface to the owning team's inbox.

No threads yet. Be the first to ask, or to share what you found.