FFastero

Connect any database. Ask in plain English.

Try free
Back to blog

Blog article

How to Migrate from Excel to SQL for Data Analysis

Your Excel file hit 1M rows, VLOOKUP takes five minutes, and you have three copies called "final." Here is the practical guide to moving your analysis to SQL without losing what makes spreadsheets useful.

Fastero Dev TeamFastero Dev Team
2026-08-22
excelsqldata-analysismigrationdatabases
How to Migrate from Excel to SQL for Data Analysis

To migrate from Excel to SQL, you import your spreadsheets into a database (PostgreSQL, SQLite, or DuckDB), translate your formulas to SQL equivalents (VLOOKUP becomes JOIN, SUMIFS becomes SUM with WHERE, pivot tables become GROUP BY), and run the same analysis you were doing before — just faster, on more data, and without the file crashing at 1.04 million rows.

Why you're reading this right now

You didn't wake up this morning thinking "I should learn SQL." Something broke. Maybe your workbook takes 90 seconds to open. Maybe you discovered that the VLOOKUP pulling commission rates was matching on the wrong column for three months and nobody noticed because the file is 47 tabs deep. Maybe you have a file called revenue_final_v3_FINAL_USE_THIS.xlsx and a colleague just sent you revenue_final_v3_FINAL_USE_THIS_UPDATED_JUL.xlsx.

These aren't signs that you're bad at Excel. They're signs that you've outgrown it. Excel is a brilliant tool that was designed for workbooks with thousands of rows, not millions. The ceiling is real: 1,048,576 rows per sheet, formulas that recalculate the entire workbook when you change one cell, no version control, no audit trail, and a file format that corrupts when it gets too large.

SQL doesn't have those limits. A PostgreSQL table can hold billions of rows. Queries run on exactly the data you ask for, not the entire file. And your analysis is a text file you can version, review, and rerun — not a binary blob that Excel sometimes refuses to open.

Here's what the two workflows actually look like:

EXCEL WORKFLOW                          SQL WORKFLOW
─────────────────                       ─────────────────
 Open 200MB file (wait 2 min)           Connect to database (instant)
 ↓                                      ↓
 Scroll to find the data                Write SELECT to describe what
 ↓                                        you want
 Add VLOOKUP to join sheets             ↓
 (wait for recalc)                      JOIN tables in the query
 ↓                                      (runs in milliseconds)
 Build pivot table (crash?)             ↓
 ↓                                      GROUP BY for aggregation
 Copy-paste into email                  (runs in milliseconds)
 ↓                                      ↓
 "Which version is current?"            Save query as .sql file

                                        Run it again next month
                                        (same results, no drift)

What database should you pick?

This is where most guides lose people. They list 15 databases and compare them on features you don't care about yet. Here are three choices, and one of them is right for you.

PostgreSQL — if you work on a team or want something that grows with you. It's free, open source, and every analytics tool in existence connects to it. Your company might already have one running. If you're going to learn one database, make it Postgres. For a deeper comparison on analytics use cases, see our DuckDB vs Postgres breakdown.

SQLite — if you're a solo analyst who wants something as simple as Excel. SQLite is a single file, no server, no installation beyond downloading one binary. You can email a SQLite database to a colleague the same way you'd email a spreadsheet. The downside: it's not designed for concurrent users or heavy analytical queries.

DuckDB — if your workflow is "I have CSV and Excel files and I want to query them." DuckDB reads CSV, Parquet, and Excel files directly with zero import step. It's becoming the default choice for analysts who think in files rather than servers.

You don't need to decide forever. Start with DuckDB if you want to keep working with files. Move to PostgreSQL when you need shared access or your data lives in a real database.

Fastero

Connect your database. Ask questions. Get dashboards.

Postgres, BigQuery, Snowflake, and 10+ sources — live-connected, AI-powered, no dashboard builder learning curve.

Try free →

How do you actually import your data?

This is the part that feels scary and turns out to be three commands.

DuckDB (easiest — reads your files directly):

-- No import needed. Just query the file.
SELECT * FROM read_csv_auto('sales_2025.csv');
 
-- Excel files work too
SELECT * FROM read_xlsx('revenue_report.xlsx');
 
-- Save it as a proper table if you want
CREATE TABLE sales AS
  SELECT * FROM read_csv_auto('sales_2025.csv');

PostgreSQL (for when you need a real database):

-- Create a table that matches your spreadsheet columns
CREATE TABLE sales (
  order_date  DATE,
  customer    TEXT,
  product     TEXT,
  quantity    INTEGER,
  unit_price  NUMERIC(10,2),
  revenue     NUMERIC(12,2)
);
 
-- Import the CSV
COPY sales FROM '/path/to/sales_2025.csv'
  WITH (FORMAT csv, HEADER true);

GUI option: If commands aren't your thing, DBeaver (free) has an import wizard — right-click a table, select "Import Data," point it at your CSV or Excel file, and click through. Five clicks, done. We cover DBeaver and other options in our SQL editor comparison.

What's the SQL equivalent of my Excel formula?

This table is the one you'll bookmark. Every Excel function you rely on has a SQL equivalent, and the SQL version is almost always shorter.

Excel SQL What it does
VLOOKUP(A2, Sheet2!A:C, 3, FALSE) SELECT ... FROM orders JOIN customers ON orders.customer_id = customers.id Match a value in one table to look up a value in another
Pivot table (drag Revenue to Values, Product to Rows) SELECT product, SUM(revenue) FROM sales GROUP BY product Aggregate by category
SUMIFS(D:D, B:B, "Widget", C:C, ">100") SELECT SUM(revenue) FROM sales WHERE product = 'Widget' AND quantity > 100 Conditional sum
IF(A2>100, "High", "Low") CASE WHEN quantity > 100 THEN 'High' ELSE 'Low' END Conditional logic
INDEX(MATCH(...)) Subquery or CTE Flexible lookup (see example below)
COUNTIFS(B:B, "Widget", C:C, ">0") SELECT COUNT(*) FROM sales WHERE product = 'Widget' AND quantity > 0 Conditional count
Filter button + sort WHERE ... ORDER BY ... Filter and sort rows
Remove Duplicates SELECT DISTINCT ... Unique values
CONCATENATE(A2, " ", B2) first_name || ' ' || last_name Combine text

The biggest mental shift: in Excel, you write a formula in a cell and it operates on a range. In SQL, you write a query that describes the result you want, and the database figures out how to compute it. You stop thinking in cells and start thinking in datasets.

How do I translate my actual analysis?

Let's take a real example. Say you're calculating monthly revenue by product category, with a running total — something that's a pivot table plus a helper column in Excel.

The Excel way (roughly):

  1. Create a pivot table with Month in rows, Category in columns, SUM of Revenue in values.
  2. Add a helper column next to each category with =SUM($B$2:B2) dragged down for the running total.
  3. Pray the pivot table doesn't rearrange your helper column references when you refresh.

The SQL way:

SELECT
  DATE_TRUNC('month', order_date) AS month,
  category,
  SUM(revenue)                    AS monthly_revenue,
  SUM(SUM(revenue)) OVER (
    PARTITION BY category
    ORDER BY DATE_TRUNC('month', order_date)
  )                               AS running_total
FROM sales
GROUP BY month, category
ORDER BY category, month;

That's it. Seven lines. It handles any number of months, any number of categories, and you can re-run it next quarter without touching anything. The OVER clause (a window function) gives you the running total without helper columns or copy-paste formulas.

Here's a more involved example — the kind of thing that becomes a nightmare of INDEX/MATCH in Excel. Find each customer's first purchase date and what they bought:

WITH first_purchases AS (
  SELECT
    customer_id,
    MIN(order_date) AS first_order_date
  FROM sales
  GROUP BY customer_id
)
SELECT
  s.customer_id,
  s.order_date,
  s.product,
  s.revenue
FROM sales s
JOIN first_purchases fp
  ON s.customer_id = fp.customer_id
 AND s.order_date  = fp.first_order_date
ORDER BY s.revenue DESC;

The WITH clause (a Common Table Expression, or CTE) is like a named sub-spreadsheet. You define it once and reference it in the main query. In Excel, this would be a helper sheet with a MINIFS formula, then a VLOOKUP back to the original data, then a prayer that nobody deletes the helper sheet.

What SQL editor should I use?

You need somewhere to write and run your queries. Three options, pick one, and move on:

  • DBeaver (free, open source) — connects to everything, has a visual query builder, auto-completes table and column names. This is where most people should start.
  • VS Code + SQLTools extension (free) — if you already live in VS Code. Lighter than DBeaver but still solid.
  • DataGrip (paid, JetBrains) — the best SQL IDE on the market, but costs $100/year. Worth it if SQL becomes your primary tool.

All three connect to PostgreSQL, SQLite, DuckDB, and basically every other database. Pick one, connect it to your database, and start writing queries.

For a deeper comparison with more options, see our full SQL editor roundup.

Should I keep using Excel for anything?

Yes. Excel is still the best tool for several things, and pretending otherwise is dishonest.

Keep Excel for:

  • Quick data entry — typing 50 rows into a spreadsheet is faster than writing INSERT statements
  • Ad-hoc charts for a meeting — you need a bar chart in 30 seconds, not a reproducible analysis pipeline
  • Sharing with people who won't learn SQL — your CFO wants a spreadsheet, not a database connection string
  • Small, one-off calculations — sometimes a calculator with a grid is exactly what you need

Move to SQL when:

  • Your data exceeds 100k rows (Excel gets sluggish) or 1M rows (Excel literally cannot)
  • Multiple people need the same data and you're emailing files back and forth
  • You need an audit trail — who ran what analysis, when, and what did it show
  • Your formulas reference other sheets that reference other sheets that reference a file on someone's desktop
  • The analysis needs to run again next month with new data

The sweet spot for most analysts is both. SQL for the heavy analytical work, Excel for the last-mile formatting and sharing. They aren't enemies.

What about visualization?

SQL gives you the data. You still need something to make charts. A few paths:

  • Export query results to Excel or Google Sheets and chart there (the pragmatic option).
  • Use your SQL editor's built-in charting (DBeaver has basic charts).
  • Connect a visualization tool directly to your database.
  • Or use Fastero — upload your Excel file or connect your database, and ask questions in English or SQL. The charts generate from the query results automatically.

What if I don't want to set up a database at all?

Honest answer: most analysts who hit Excel's limits don't actually want to become database administrators. They want to query their data without it crashing. That's a reasonable ask.

This is what Fastero does. Upload your Excel file, and it's queryable — with SQL if you know it, or with plain English if you don't. No PostgreSQL installation, no COPY commands, no connection strings. Your spreadsheet becomes a table, and you can JOIN across multiple files the way you'd VLOOKUP across sheets, except it works on millions of rows and doesn't corrupt when you close your laptop lid.

If you're also deciding between SQL and Python for your analysis work, our SQL vs Pandas comparison breaks down when each approach makes sense.

FAQ

Do I need to learn SQL before migrating? You need about 6 keywords to replace 90% of what you do in Excel: SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY. That's a weekend of practice, not a bootcamp. Start by translating one analysis you already know how to do in Excel. The table above maps every common formula to its SQL equivalent.

Will I lose my existing Excel files? No. Migration doesn't mean deletion. Import your data into a database, keep the original Excel files as archives. Most teams run both side-by-side for months before fully transitioning. And tools like DuckDB can query Excel files directly without importing — your .xlsx files stay exactly where they are.

Can SQL do everything Excel does? Almost. SQL is stronger at joins, aggregation, filtering large datasets, and reproducible analysis. Excel is stronger at free-form data entry, quick formatting, and sharing with non-technical colleagues. The gap is conditional formatting and cell-level visual styling — SQL doesn't do that. For presentation, you'll still export to Excel or a charting tool.

How long does the migration take? For a single workbook: an afternoon. Install DBeaver, import your CSV, and translate your key formulas to SQL queries. For a team with dozens of critical spreadsheets: a few weeks of gradual transition, converting one workflow at a time. Don't try to migrate everything at once. Pick the spreadsheet that causes the most pain and start there.

What if my team doesn't know SQL? Two options. First, invest in training — SQL basics take a week to learn, and the productivity gains are permanent. Second, use a tool that lets you query data in plain English and generates the SQL for you. Fastero does exactly this: your team asks questions in words, sees the SQL that produced the answer, and gradually learns the syntax by reading real queries against their own data.


Try Fastero free — upload your Excel file, query it with SQL or plain English. No database setup, no VLOOKUP. No credit card required.

Ready to try it yourself?

Connect your database, ask questions in plain English, and get live dashboards — in under 2 minutes. No credit card required.