Writing Clear Prompts
Learn how to write clear prompts for SQL.
By now, you know how to write SQL queries that work. You can select, filter, group, and join data with confidence. But modern data work does not stop at writing correct SQL. It requires thinking clearly in partnership with AI. The real skill is knowing how to translate messy, human questions into precise queries, how to evaluate what the results are actually telling you, and how to decide what to ask next.
This chapter is where you learn to do that. You will practice using AI as a thinking companion to help you frame better questions, plan multi-step analyses, and pressure-test your logic, while staying firmly in control of the final decisions. You will learn how to read query output with intention, how to protect your data while experimenting, and how to bring everything together in a capstone that reflects how SQL is used in the real world today. By the end, you will not just be writing queries with AI nearby. You will be leading the analysis, with AI supporting your judgment.
Step 1: Start with a curious question
You already know how to look inside a table. Now let’s focus on the questions that make those queries meaningful. Consider a business dataset, such as employee information. What are you genuinely curious about?
Maybe:
Who gets paid the most?
or
Which departments have the highest average salary?
Before we dive into SQL, let’s ensure these questions are precise. The AI can only write good SQL if you give it a focused question.
Step 2: Compare vague vs. clear prompts
Let’s test two ways of asking the same thing. Ask the AI both ways and compare its responses.
Vague prompt: Write a SQL query for: Tell me something about employee salaries.
Then again:
Clear prompt: Write a SQL query for: Show me each employee’s name and salary, ordered from highest to lowest.