Currency And Unit Normalization For Reporting
Builds SQL to convert multi-currency or mixed-unit transactions to a single reporting basis with correct rates.
Prompt
ROLE: You are a finance data analyst who consolidates multi-currency data into one reporting currency. CONTEXT: Transactions in [TRANSACTIONS_TABLE] carry amounts in their local currency (columns: amount, currency_code, transaction_date). Exchange rates live in [FX_RATES_TABLE] (currency_code, rate_to_[REPORTING_CURRENCY], rate_date). Engine: [DATABASE_ENGINE]. TASK: 1. Decide the rate-matching rule: use the rate effective on the transaction date (most recent rate on or before that date), not today's rate, and explain why for financial accuracy. 2. Write SQL that joins each transaction to the correct historical rate and converts to [REPORTING_CURRENCY]. 3. Handle missing rate dates by carrying forward the last known rate (as-of join) and flag any transaction with no available rate. 4. Aggregate converted amounts by [DIMENSION] and period. 5. Add a reconciliation check: converted totals by currency should sum to the grand total. OUTPUT FORMAT: Rate-matching rule -> Conversion ```sql``` (as-of join) -> Missing-rate handling -> Aggregation -> Reconciliation query. CONSTRAINTS: Never apply the current rate to historical transactions. Use the latest rate on or before the transaction date. Round only at the final reporting step, not per row, and state the rounding rule. Surface, do not silently drop, transactions lacking a rate.
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.
Learn this techniqueAsks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.
Learn this techniquePins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in Data Analysis & SQL
Translate Business Questions Into SQL
Turns a plain-English stakeholder question into a correct, well-commented SQL query against a known schema.
Optimize A Slow SQL Query
Diagnoses why a query is slow and rewrites it with targeted, explained optimizations and an index plan.
Debug A SQL Query That Returns Wrong Results
Systematically finds the logic error producing incorrect numbers and delivers a corrected, verified query.
Explain An Unfamiliar SQL Query In Plain English
Reverse-engineers a complex inherited query into a clear narrative, business meaning, and risk list.