How Finance Professionals Can Use AI to Write SQL (Without Being an Engineer)

Lillian Hawasli
Lillian Hawasli
Data Engineer @ Renaissance
Blog
|
July 31, 2026

A few years ago, being the finance person who could write SQL was a genuine superpower. Today the ground has shifted. You still need to understand data, but the actual writing of queries can increasingly be handed to an AI tool. That does not make the skill less valuable. It changes what the skill is. The professionals who win now are the ones who know how to direct an AI to write good SQL, and how to catch it when it gets things wrong.

Here is the complete workflow that actually works, the tools worth using, real prompts you can copy, and the foundation you still need for any of it to be safe.

The New Reality

Large language models are genuinely good at writing SQL. Describe what you want in plain language, give the tool the right context, and it will produce a query in seconds that would have taken you real time to write by hand. The bottleneck is no longer syntax. It is knowing what to ask for, and knowing whether the answer that comes back is actually correct.

That is good news for finance professionals, because it means the barrier to getting your own data has dropped dramatically. But it comes with a catch that is easy to miss: an AI will confidently hand you a query that runs perfectly and returns completely wrong numbers. There is no error message for a query that answers the wrong question. Protecting yourself from that is the whole skill.

The Foundation You Still Need

You cannot direct what you do not understand. To prompt an AI well and to check its work, you need the basics: what tables exist, what columns live in them, what each field actually means, and how the tables relate to one another. That is the non negotiable foundation, and if you are not there yet, start with our guide on how much SQL you actually need for strategic finance before you lean on AI.

With that foundation in place, the AI becomes a genuine force multiplier rather than a black box you are blindly trusting. Here is how to use it.

Which AI Tools Actually Work for SQL

Most of the general purpose assistants are strong at SQL, and any of them will serve you well: ChatGPT, Claude, and Gemini all write clean queries and explain them clearly. Beyond the general tools, many modern database and analytics platforms now have AI query assistants built directly into them, and some data warehouses offer a natural language to SQL feature so you can ask for data in plain English inside the tool itself. You do not need a specialized product to start. The assistant you already use is almost certainly good enough. What matters far more than the specific tool is the workflow you wrap around it.

The Workflow, Step by Step

The loop is simple, and once you internalize it you will use it every day on the job.

First, give the AI your schema. Tell it the tables you are working with and the columns inside them. A quick way to do this is to take a screenshot of your table structure and drop it straight into your AI tool, or paste the column list. The more context it has about your actual data, the better its queries will be.

Second, describe the problem in business terms. You do not need to speak in SQL. Say what you are trying to figure out, for example the number of active subscriptions by plan for last quarter, or revenue by customer segment month over month. Let the tool translate the business question into the query.

Third, ask it to write the query and explain it. Requesting a plain language explanation alongside the query is not optional in my view. It is how you learn, and it is how you catch flawed logic before you run anything.

Fourth, read the query before you trust it. You are not proofreading syntax, you are checking the logic. Is it joining the right tables in the right way? Are the filters correct? Is the date range what you meant? Is it counting at the right level, so you are not accidentally multiplying rows through a bad join?

Fifth, run it and verify against something you know. Sanity check the output against a number you already trust, even a rough one. If total revenue comes back at ten times what you expected, a join is duplicating rows. If it comes back suspiciously low, a filter is too aggressive.

Sixth, iterate. Tell the AI what was off and ask it to adjust. This back and forth is normal and fast, and it is where most of the real work happens.

A Worked Example

Say you want quarterly revenue by subscription plan. Here is how the loop looks in practice.

You give the AI your two tables, customers and subscriptions, and their columns. Then you prompt it: using the subscriptions table, give me total revenue grouped by plan for the second quarter, joined to customers so I can also see the customer segment. The AI returns a query that joins the two tables, filters to the quarter using the date column, groups by plan and segment, and sums the revenue.

Now you check it. Does the join key match on customer id? Is the date filter capturing the right three months? Is it summing the right revenue column? You run it, and total revenue comes back roughly double what you expected. That is the classic signature of a join creating duplicate rows, often because a customer has more than one subscription. You tell the AI exactly that, it adjusts the logic to count each subscription once, and the number lands where it should. That five minute loop, not the raw query writing, is the actual skill.

Prompts You Can Steal

A few reliable prompt patterns to keep in your back pocket. Ask the tool to act as a SQL expert and explain each query it writes. Give it your schema and ask what analyses are even possible with the tables you have, which is a great way to explore new data. When you have a business question, phrase it as here are my tables and columns, help me write a query that answers this specific question. And when a result looks off, paste the query back and ask it to check the query for anything that might cause duplicate rows or an incorrect total. Prompts like these turn the AI from a code generator into a genuine analysis partner.

How to Prompt for Better Queries

A few habits produce dramatically better results. Be specific about the exact table and column names rather than describing them vaguely. Give the tool a couple of sample rows so it understands the shape of your data. State the grain you want, meaning the level of detail, such as one row per customer or one row per month. And ask the AI to flag any assumptions it made, because those assumptions are exactly where wrong answers hide.

A Critical Warning on Data Privacy

One rule that matters more than any prompt trick: never paste real, sensitive company data into a public AI tool. Actual customer records, revenue figures, and personally identifiable information should not be dropped into a consumer chatbot, because you may be handing confidential data to a third party in violation of your company's policy. The safe approach is to share only the structure of your data, the table and column names, rather than the underlying rows, or to use an approved, enterprise grade tool that your company has cleared for this purpose. You can get almost all of the benefit by giving the AI the schema and a couple of fake sample rows, never the real thing. Check your company's policy before you start.

The Traps to Avoid

The failure modes are predictable once you know them. Wrong joins are the most common and the most dangerous, because they silently duplicate rows and inflate your totals. Date filters go wrong quietly, capturing too much or too little without any signal. Duplicate rows sneak into results and skew every aggregate. And the biggest trap of all is trusting output you have not verified. Every one of these is caught by the same thing: understanding your data well enough to know when a number cannot be right. That is why the foundation matters, and why AI makes it more important, not less.

Where AI Still Falls Short

For all its strengths, an AI tool has real limits you should respect. It does not know your business context, so it cannot tell you which of two similar tables is the trustworthy one, or that a certain field was deprecated last year. It cannot know that your fiscal year starts in February, or that a particular customer segment is defined a specific way at your company, unless you tell it. And it cannot verify its own output against reality. Those gaps are exactly where your judgment, and your knowledge of the business, remain irreplaceable. The AI writes the query. You own the answer.

Practice the Loop Safely

The best way to build this muscle is to run the loop on real tables where the stakes are zero. We built a free practice database called the SFC Data Lab for exactly this. It gives you real tables and columns that mimic what you would see on your first day on the job, plus a set of assignments that are deliberately on the harder side, precisely so you practice solving them with an AI tool rather than by hand. Take a screenshot of the tables, drop them into your LLM, and work the loop. You can start right now at data.strategicfinancecareers.com.

Our founder Zu also demonstrates this exact day one workflow in a short video you can watch here. If you want to know which specific query patterns to practice first, we broke down the essential ones in our list of SQL queries every strategic finance analyst should know.

Frequently Asked Questions

Can AI really write SQL for me? Yes. Modern AI tools write accurate SQL quickly when you give them your table structure and a clear question. Your job is to direct the tool and verify the result, not to write every query by hand.

Which AI tool is best for writing SQL? The major general assistants all handle SQL well, and many databases now have AI query features built in. The specific tool matters less than the workflow you use around it.

Is it safe to use AI to write SQL at work? It is, as long as you do not paste real sensitive data into a public tool. Share the structure of your data rather than the actual rows, and follow your company's data policy.

Do I still need to learn SQL if AI can write it? Yes, the foundation. You need to understand tables, columns, and joins well enough to prompt effectively and to catch wrong answers, which AI will produce without warning.

The finance professionals who thrive from here are not the ones who memorized the most syntax. They are the ones who understand their data deeply and know how to point a powerful tool at it. That is a skill you can build starting today.

Related posts