HOW-TO 198 · Productivity, HR and Technical Skills

How to write a basic SQL query

You need to retrieve records from a database without changing the data. The method below walks you through the work without assuming you know the software.

Before you start

FILE OPTIONAL: a relevant existing document. If you have it, select + or the paperclip, choose Upload file and wait until its name appears. Otherwise start a new chat and describe what you need. Never upload confidential material to an unapproved tool.

YOUR READY-TO-USE PROMPT

Copy this into your AI tool

I need help writing a basic SQL query, but I am a beginner. Ask one question at a time about what information I want, my database software, table names, available columns and filters. Explain any technical term immediately. Then produce a read-only SELECT query and walk me through what each line does. Use an example with fictional records if I cannot share real database information. Show me how to test with a small result set and how to check that I am querying the correct table. Do not include commands that change or delete data.
Paste it into an AI application and answer its questions.
Example, follow-up prompt and final checks

Example conversation

AI might ask: What information do you want from your database?

You might reply: A list of customer account openings by month.

Example result

SELECT branch, COUNT(*) AS accounts
FROM example_accounts
GROUP BY branch;
(Read-only example with fictional table name.)

Improve your result

Use a safe test copy before touching live systems, and confirm any change with the authorised owner.

Add grouping and a count by one category if appropriate.

Before you use it

Run only on an authorised database and check sample rows.