Should I Learn SQL or Python First?
By Owen Middleton · Updated October 2026 · We ran the examples on PostgreSQL 17
In our view, learn SQL first for a data analyst job. Learn Python first for data science.
In one US study of data analyst job posts, employers asked for SQL in 52.9% and for Python in 31.2%. In a study of data scientist posts on Monster, the figures were 30% for SQL and 57% for Python (78% the year before). You can learn SQL with no Python.
We make SQLMaxx Learn, a free SQL course. We teach only SQL and we have no Python course, so we gain when you start with SQL.
Do employers ask for SQL or Python in data job posts?
For data analyst jobs, employers asked for SQL more often. For data scientist jobs, they asked for Python more often. These figures are from one publisher, 365 Data Science, with three studies. In each study, the authors collected 1,000 job posts and kept only the posts that they judged relevant.
- Data analyst: SQL 52.9%, Python 31.2%. 855 posts from Indeed; country: US; page date: 28 Apr 2026.
- Data scientist: SQL 30%, Python 57%. 827 posts from Monster; country: not stated; page date: 28 Apr 2026.
- Data engineer: SQL 79.4%, Python 73.7%. 703 posts from Indeed; country: US; page date: 23 Apr 2026.
Read the table with these limits:
- The data analyst and data engineer posts are from Indeed, in the US. The data scientist posts are from Monster, and the authors do not name a country.
- In the data scientist study, employers asked for Python in 78% of the posts in 2024 and in 57% in 2025. For SQL, the figure for the year before was 60%. So do not read one year of posts as a trend.
- The authors put 2026 in each study title, but they label the data engineer charts 2024.
- The years of the data are not the same. In the data scientist study, the authors give figures for 2024 and 2025. In the data analyst study, the authors give a year only in the title, not for the data.
- 365 Data Science first published each study page in 2024. The page date in the table is the date on each page now.
- 365 Data Science sells data science courses, with courses in SQL and in Python.
Most learners in one large survey worked in Python in the past year. In the Stack Overflow Developer Survey 2025, 2,564 respondents in the group "Learning to Code" answered the question about languages. Of them, 71.8% did extensive development work in Python in the past year. The figure for SQL was 45.4%. Stack Overflow did not ask which language the learners started with.
Most of these learners did no extensive work in SQL in the past year. So we give SQL first as advice for one goal only, the data analyst job.
Python is also a language for work outside the database. On python.org, the authors of the page "Applications for Python" name web development, "scientific and numeric computing", education and desktop programs. In our view, if you do not have a job goal yet, start with Python, because you can use it for more types of work.
Can I learn SQL without knowing Python?
Yes. SQL is a separate language. You write a SQL query, and PostgreSQL runs it and gives you the result. You do not need a Python step.
In SQLMaxx Learn, you need no Python and no installation. You write each query in your browser, in a real PostgreSQL database.
What does one data question look like in SQL and in Python?
Here is one question about a small sample store: which 5 countries have the largest total amount of delivered orders? In the store, there are 161 delivered orders, from customers in 18 countries. Each country is a two-letter code, for example US and GB.
Schema · ecommerce2 tables? = nullable
SQL (PostgreSQL)
SELECT c.country, SUM(o.total_amount) AS revenue
FROM customers AS c
JOIN orders AS o ON o.customer_id = c.id
WHERE o.status = 'delivered'
GROUP BY c.country
ORDER BY revenue DESC
LIMIT 5; | country | revenue |
|---|---|
| US | 32840.91 |
| CA | 13175.98 |
| GB | 13148.00 |
| KR | 5541.00 |
| JP | 4887.99 |
Python (pandas)
Shown as an example. Not run on this page.
import pandas as pd
# conn: a SQLAlchemy connection to the store database (not shown)
customers = pd.read_sql("SELECT id, country FROM customers", conn)
orders = pd.read_sql("SELECT customer_id, status, total_amount FROM orders", conn)
delivered = orders[orders["status"] == "delivered"]
joined = delivered.merge(customers, left_on="customer_id", right_on="id")
revenue = (
joined.groupby("country")["total_amount"].sum()
.reset_index(name="revenue")
.sort_values("revenue", ascending=False)
.head(5)
)Change the SQL query and run it here. For example, use 'shipped' in place of 'delivered':
SELECT c.country, SUM(o.total_amount) AS revenue FROM customers AS c JOIN orders AS o ON o.customer_id = c.id WHERE o.status = 'delivered' GROUP BY c.country ORDER BY revenue DESC LIMIT 5;
You can match each step of the pandas version to a part of the SQL query:
- The filter on
statusis theWHEREclause. mergeis theJOIN. Its default type is an inner join.groupbyandsumareGROUP BYandSUM.sort_valuesisORDER BY, andhead(5)isLIMIT 5.
The pandas authors give the same match for GROUP BY in their
comparison with SQL. In this pandas version, you get the data from
the database with pandas.read_sql, and you give it a SQL query
(pandas documentation).
We chose a question for which SQL is a good fit: an aggregate over tables in a database. With pandas, you can
also read data with no SQL. For example, you read a CSV file with
pandas.read_csv and an Excel file with
pandas.read_excel.
Can I learn SQL and Python at the same time?
In our view, yes, but start with one language. We found no study about the best order. This is our advice for the best way to learn SQL and Python:
- For a data analyst goal, learn the SQL basics before Python: SELECT, WHERE, JOIN and GROUP BY. Then learn Python with pandas.
- For a data science goal, learn Python first. Then learn SQL.
- In the second language, solve questions that you solved in the first language, as in the example above.
Later, you can use both languages in one program. In the Python standard library, there is a module for SQL:
sqlite3, a "DB-API 2.0 interface for SQLite databases".
With it, you run SQL on a SQLite database from Python. The SQLite authors call SQLite
"an embedded SQL database engine". The Python authors call it "an optional module", so a
copy of Python can be without it.
What do you already know from Python when you learn SQL?
Is SQL like Python? In some ways, yes. If you learn SQL after Python, you already know some of the ideas of SQL. Here are two, and one difference.
Data types in Python and in SQL
In Python, a whole number is an int and text is a str
(Python documentation). In SQL, each column is of one data type. In the sample
store, customers.id is an INTEGER column and customers.name is a
TEXT column.
The rules are not the same. The Python authors write that integers have "unlimited precision". In PostgreSQL,
you get an error when the result of +, -, * or / on
INTEGER values is out of the INTEGER range:
SELECT 2147483647 + 1; For the SQL types and casts, see the lesson Literal Values, Data Types, and Type Casting, with live examples.
A Python list and the values of a SQL group
In Python, you put many values in a list. In SQL, you can put the values of each group into one value. With
STRING_AGG, you join them into one text value:
SELECT country, STRING_AGG(name, ', ' ORDER BY name) AS names
FROM customers
WHERE country IN ('AT', 'MX')
GROUP BY country
ORDER BY country; | country | names |
|---|---|
| AT | Jade Evans, Kyle Ford |
| MX | Zane Torres |
With ARRAY_AGG, you put them into an array. For text values, the type of the array is
text[]. For both functions, see the STRING_AGG and ARRAY_AGG lesson.
In SQL, you describe the result, not the steps
In Python, you write the steps in order. In SQL, you describe the result that you want, and PostgreSQL selects the steps. The PostgreSQL authors write that PostgreSQL can execute a query "in a wide variety of different ways, each of which will produce the same set of results" (PostgreSQL 17 documentation, Planner/Optimizer).
Where can you learn SQL and Python?
In SQLMaxx Learn, you learn SQL for free in 66 lessons, with a check of each answer in a real PostgreSQL database.
Lesson 1 is "SELECT and Column Expressions". You can start it in your browser with no account. For all 66 lessons in order, see the full SQL course.
We have no Python course. For Python, you can read The Python Tutorial, free on docs.python.org. Its authors write that it is "designed for programmers that are new to the Python language, not beginners who are new to programming". If you are new to code, look for a Python course for beginners.
More questions about SQL and Python
Is Python or SQL harder to learn?
You can find either one harder. Think about what you already know and what you want to do with the language. We compare how hard SQL is on a separate page: is SQL hard to learn.
What's more useful, SQL or Python?
Choose by the job that you want. In 703 US data engineer posts from a 365 Data Science study, SQL and Python were first and second. The next language was Java, at 22.6%. Source: 365 Data Science, data engineer study.
Is Python and SQL enough to get a job?
Not for every data job. In the 365 Data Science study of 827 data scientist posts on Monster, employers asked for machine learning in 69% of the posts. Source: 365 Data Science, data scientist study.