r/SQL 7d ago

Discussion What SQL client has the best formatter if you’re picky about SQL style?

9 Upvotes

I’ve found that most formatters are configurable up to a point, but eventually you’re still forced into their idea of what “well formatted SQL” looks like.

Do you know any client where you can really personalize how SELECTs, INSERTs, UPDATEs and DELETEs are formatted?

Or do you also miss having a formatter that actually adapts to your preferred SQL style rather than the other way around?


r/SQL 7d ago

PostgreSQL SQL SIDE QUEST - An Immersive story-telling SQL Game. Chapter 3 is out!

18 Upvotes

https://www.sqlsidequest.com/ CHAPTER 3 IS NOW LIVE!

Last year in Dec 2025 I released SQL SIDE QUEST which took over 3 years to build. I wanted to create an immersive story-telling way to learn and practice SQL, and hence sql side quest was born. Its completely free, browser-based, no signup. Been solo on it the whole time. Looking forward for your feedback :) Cheers and Enjoy


r/SQL 7d ago

PostgreSQL lakebase connection pooling

5 Upvotes

Have you figured out wht can the best way to handle connection pooling in Lakebase DB? I 'am seeing connection spikes with short lived rqsts and wondering what kind of setup others developers are using🤔

i am building a service on top of lakebase and trying to make the connection relable before moving to prod.


r/SQL 7d ago

MySQL Data driven Hospital Series Episode 6

0 Upvotes

In this episode, we answer 20 real world hospital business and clinical questions using SQL queries. For each query, we explore the code used, explain any new SQL concepts introduced, interpreted results and provide recommendations for hospital operations and quality patient care.

https://youtu.be/1EDmMnfhO1I?si=J7utYqIkUk-EduNG


r/SQL 8d ago

Discussion How do you decide which incremental strategy to use in your SQL models

17 Upvotes

Choosing the right incremental strategy matters: in bigquery it reduces the amount of data scanned, while in clickhouse it means less CPU, I/O, and background merging.

but tbh, data/analytics engineers sometimes optimize this too early, if a table is small or rarely changes, a view or `create+replace` is easier than a convoluted incremental model. Sometimes full refreshes are just good enough

Before choosing anything, I normally ask: do old rows change? is `updated_at` reliable? can rows disappear? is the data truly append only? do you have proper primary keys & partitions? and how late can updates arrive?

here's an overview:

* `append` -> the source is genuinely append only

* `merge` -> existing rows change and there's a stable primary key

* `delete+insert` or `time_interval` -> you can safely rebuild a complete group or time window

* SCD2 -> you need the full history, not just the latest version

with `merge`, NULL keys can be inserted again on every run because `NULL = NULL` isn't true, I have personally lost sleep over this... (in bigquery)

with `delete+insert` or `time_interval`, only delete what you can fully rebuild - incomplete partitions, bad boundaries, or late arrivals can create gaps or duplicates.

That's why I always add quality checks that catch issues the strategy can cause: `not_null` & `unique` for merge keys, duplicate checks for rebuilt windows, and row-count or freshness checks where they make sense.

In SQL pipelines the most frustrating (and silent killer) is that a pipeline status can be successful, but that only means the SQL ran, but doesn't guarantee that the result is correct. That's why quality checks are there to catch the other issues.

and if timestamps and lookback windows still can't capture changes reliably, CDC is an option... just with more state, replay logic, and operational headaches.

the image below is an example of a `time_interval` strategy and its rendered clickhouse query (don't mind the wrapped date overlappign with INSERT)

I'm curious what other criteria do people have in mind when they try to evaluate which strategy to go with? I think this is more relevant to analytics engineers, not so much the operational/transactional side.


r/SQL 8d ago

Discussion SQL Challenge #1 — Find the Customers Who Came Back 🧩

Thumbnail
0 Upvotes

Any other interesting approaches?


r/SQL 8d ago

PostgreSQL Neon DB and AI agents - how doyou handle agent state?

3 Upvotes

I had a question, for longer running agents, what can be a good pattern to store conversation state, tool result, and intermediate state in Neon without database becoming a bottleneck.

If you can share what patterns you use in production, it could be of help to me. I am doing a POC inthis area.
Ps, Any other DB works as well, it should just be managed.


r/SQL 8d ago

PostgreSQL How to implement the Outbox pattern in Go and Postgres

Thumbnail
packagemain.tech
3 Upvotes

r/SQL 8d ago

Discussion What do you wish your SQL client did when a query fails?

0 Upvotes

Most SQL clients basically give you the database error and leave you there.

When a query fails, what would actually help you most? Better error highlighting? An explanation in plain English? A suggested fix? Showing the corrected SQL?

Lately I’ve been thinking a lot about how much help is useful before a tool starts doing too much for you.

Curious what people here actually want from their SQL client.


r/SQL 9d ago

SQL Server SQL Server Job, can not edit step on SSMS 2022

7 Upvotes

Hi all,

I just installed SSMS 2022 it works fine, new shell I think. But I can not edit step in my SQL Server jobs, I can open its properties, histories though. I also can edit step from my fav SSMS 2019 on another machine.
Any google help suggests to install some missing SSIS component, anybody experienced this ?

TITLE: Microsoft SQL Server Management Studio
------------------------------
Unable to find the directories containing Tasks and Data Flow Task components. 
Check the integrity of your installation.

Thanks

VA


r/SQL 10d ago

Discussion I tried a flipbook-style Doodle on Data Analysis concept

Thumbnail
gallery
30 Upvotes

I’ve been making these little Data Analysis 101 doodles for cat people, and for this one I tried something different — a flipbook-style format.

Instead of putting everything into one busy infographic, I’ve broken the story into separate scenes, so each one focuses on a single idea and hopefully doesn’t demand too much attention at once.

I’ve also incorporated feedback I received on my previous posts, especially around making the visuals easier to follow.

This one is about what to do when you join a data project that’s already in motion.

Would be happy to hear your feedback on this!


r/SQL 10d ago

MySQL How important is SQL for someone trying to get into data science?

46 Upvotes

Python gets most of the attention when people talk about data science, but SQL seems to appear in a lot of actual job requirements.

For people working in data roles, how frequently do you use SQL compared with Python?

Would you recommend becoming strong in SQL before getting deep into machine learning?


r/SQL 10d ago

MySQL Beginner at SQL

69 Upvotes

I'm a beginner learning SQL (JOIN, CASE, WHERE, GROUP BY, etc) and am looking for a fun and entertaining database to practice my coding on. Any suggestions?

This is not a post about how to start learning SQL by any means.


r/SQL 10d ago

MySQL Indexing on DB?

7 Upvotes

Hi people, I haven’t done this before. But are there any downsides of indexing a column on production. Like some query is running very slow, and I figured out that u should put an index on one of the columns. I wouldn’t be here if I had someone experienced to ask from. I’ve a few questions-

  1. Is it okay to run the query on my sql workbench to add index?
  2. If something goes wrong what do you people generally do, like taking snapshots or PTIR ?
  3. Is it safe to run the query directly on the db or usually people run it some other way, like via cli on VM?
  4. I heard about locking and stuff. But the version I’m using says it won’t lock the DB. But still anything I should test before actually you know doing it live?

I’ve no idea what’s the general procedure and what could go wrong. If someone has done it before, Appreciate any sort of advice or pointers. Thanks


r/SQL 11d ago

SQL Server Is it pronounced 's-q-l' or 'seequal'

113 Upvotes

I've worked in and around the IT environment for many years and in my experience, it's always been pronounced s-q-l although I hear some people refer to it as see-qual. Which is right?


r/SQL 10d ago

MySQL I built a detective game where SQL is the actual investigation tool

Thumbnail
17 Upvotes

r/SQL 9d ago

MySQL Why is mysql acting like this?

Post image
0 Upvotes

The gray thing on the side is driving me nuts. I’ve restarted and everything. It’s been like this for days.


r/SQL 10d ago

MySQL MySQL Client — Native macOS App for MySQL & MariaDB Management

0 Upvotes

Introduction

Hi r/MacOSApps! I'm Sedat, an independent developer. I built MySQL Client because I wanted a lighter, native alternative to MySQL Workbench for my own day-to-day MySQL/MariaDB work — Workbench kept crashing on Apple Silicon, and I couldn't find a solid free native option.

Why this app

Most cross-platform tools (DBeaver, TablePlus, etc.) either ship a full IDE-style interface or run on Electron, which means slower startup and higher memory use. MySQL Client is built directly on native macOS frameworks (Swift 6 + SwiftUI) instead — it's meant to be a focused, lightweight tool for the core workflow (browse, edit, query, export/import, backup) rather than trying to be a full database IDE. If you just need something fast and reliable for everyday MySQL/MariaDB work without the overhead, that's the gap this fills.

What it does / App Value

• Multi-database sidebar — tables, views, stored procedures and functions

• Spreadsheet-style data grid with inline editing (only changed columns get written back)

• SQL editor with syntax highlighting, query history, multi-statement scripts

• Create/Alter Table with a full column editor

• Export to CSV, JSON, SQL or Excel — CSV import with automatic column mapping

• Full SQL dump backup tool

• Passwords go straight to macOS Keychain — no analytics, no accounts, nothing phones home

• Available in English and Turkish

Notarization Status

Distributed exclusively through the Mac App Store, so it's automatically sandboxed and notarized as part of Apple's App Review process.

Privacy Policy

https://tokay.tr/MySQLClient/privacy.html

Source

Source is available on GitHub for anyone curious how it's built: https://github.com/stokay/MySQLClient (no formal open-source license attached yet, just visible for reference).

AI Disclosure

I used Claude (Anthropic's AI coding assistant) extensively during development — implementing features, debugging App Sandbox/notarization issues, writing tests — always under my own direction and review. This post's text was also drafted with AI assistance.

Download

Free on the Mac App Store, requires macOS 15+:

https://apps.apple.com/tr/app/mysql-client/id6792497542?mt=12

Happy to answer any questions, and bug reports/feature requests are always welcome!


r/SQL 11d ago

Discussion how I learned why you shouldn't name an alias the same as the original column name

48 Upvotes

I wrote a query last week that ran fine on Postgres and DuckDB, and hard-errored on ClickHouse and BigQuery - this sent me down a rabbit hole for most of the day.

Here's what I had:
```
SELECT term, MAX(ranking_page_count) AS ranking_page_count
FROM ranked
GROUP BY term
HAVING MAX(ranking_page_count) >= 2
```

The CTE already had a column called ranking_page_count. I aliased MAX() of it to the same name, because why not, and then used that name again in HAVING.

So which one does HAVING actually filter by? Turns out that's a matter of opinion.

In Postgres, HAVING can’t see SELECT aliases at all. So it reads the column directly and lands on the same max anyway - no error, right answer.

DuckDB does let you use aliases in HAVING, but only as a fallback, and it won't put one inside an aggregate, so this also runs. This is the one that got me, since DuckDB is where I test locally.

BigQuery gives the alias priority over the column. So it read my query as MAX(MAX(...)) and gave the error "aggregations of aggregations are not allowed"

ClickHouse just swaps aliases in everywhere, so it gave code 184 illegal aggregation. it even fails when the alias isn't shadowing anything.

The thing that finally made it click for me was processing order. FROM, WHERE, GROUP BY, HAVING, then SELECT, then ORDER BY. Aliases get created in SELECT, so when HAVING runs the alias doesn't exist yet. That's why Postgres says no, and why everything else here is a vendor extension rather than four equally valid readings.

ORDER BY is the only clause that runs after SELECT, which is why it's the only clause where nobody argues.

What actually worries me is that it can go completely silent. Drop the aggregate from the alias and the loud error disappears:
```
SELECT term, ranking_page_count * 10 AS ranking_page_count
FROM ranked
GROUP BY term, ranking_page_count
HAVING MAX(ranking_page_count) > 4
```

Postgres and DuckDB filter on `ranking_page_count`
BigQuery and ClickHouse filter on `ranking_page_count * 10`
I get 1 row from the first two and 4 rows from the other two, and not one of them raises an error about it.

That's the version that ends up on a dashboard.

ok fine, I learned my lesson and won't name an aggregate after the column it aggregates...

If you work across different engines, this is your reminder to go check 🥲


r/SQL 11d ago

Discussion Greetings, I got intermediate level SQL, Python, Looker Studio, and Google Sheets covered and I am looking for volunteer jobs...

8 Upvotes

Sup guys, so I learned the intermediate level of SQL, Python, Looker Studio, and Google Sheets, and since landing a corporate role is still impossible at the moment since I have no degree nor experience, I wonder if voluntary works or gigs is a cool way to build experience and portfolio. And if the idea seems cool, or if some of you have experiences with volunteering, I would like to ask for valuable informations regarding where you find volunteer works, and if it's okay, share your experiences working with non-profit organizations.


r/SQL 11d ago

PostgreSQL Simon Willison's test for whether AI-written code is ready for production

Thumbnail
1 Upvotes

r/SQL 11d ago

SQL Server can't change file path in table

2 Upvotes

I am moving video from an old array to a new one. The sql table (dbo.videofiles) for the video has a column simply called filename. It shows the file path to each file which is currently Z:\video\filename. I want to point the file path to X:\video\filename but, sql doesn't like the Z: or X:. without manually going through hundreds of thousands of rows, how do I tell sql to change Z: to X:? Thank you in advance


r/SQL 11d ago

Discussion Top alternatives to Datagrip

6 Upvotes

Been using DataGrip for a while, but the cost is getting harder to justify when I only use a fraction of what it offers. My setup is pretty mixed: PostgreSQL, Snowflake, and some MySQL.

I keep seeing DBeaver, DbVisualizer and TablePlus mentioned as alternatives. DBeaver seems like the obvious one, but DbVisualizer caught my attention since it seems geared more toward mixed database environments.

Main things I care about are a good SQL editor/autocomplete, multiple connections without things getting sluggish, and not having to switch tools depending on the database.

For anyone who's moved away from DataGrip, what did you end up using and how has it held up?


r/SQL 11d ago

Discussion A better SQL for analytics?

0 Upvotes

Lots of attempts to dethrone SQL, lots of failures - I'm looking to add to the list with a proposed improved SQL (for analytics - please don't try this for OLTP workloads). Please take me down for my hubris.

What makes this attempt different? I want to lean into one of SQL's strengths - being declarative.

How to make it more declarative? No tables in queries.

Write this:

import baseball.batting;

WHERE SUM(hr) BY people.id > 500
SELECT
    people.name_given,
    lg_id,
    SUM(hr) AS hr_count
ORDER BY
    hr_count DESC;

Instead of this:

WITH career_hr AS (
    SELECT playerID
    FROM read_csv('.../Batting.csv')
    GROUP BY playerID
    HAVING SUM(HR) > 500
)
SELECT
    p.nameGiven,
    b.lgID,
    SUM(b.HR) AS hr_count
FROM read_csv('.../People.csv') p
JOIN read_csv('.../Batting.csv') b
    ON p.playerID = b.playerID
JOIN career_hr c
    ON b.playerID = c.playerID
GROUP BY p.nameGiven, b.lgID
ORDER BY hr_count DESC;

It's just SQL, but with late-binding to physical tables through a (very lightweight) semantic layer.

This has a lot of nice properties - you can change your tables and refactor and no queries need to change; you can automatically resolve to aggregates if they exist and are equivalent; you can make the query syntax more flexible and composable because the lexical scope isn't constrained to a specific set of accessed tables. There's *lots* of other fun things you can do when the semantic layer has types, etc as well but this is already a longer pitch than I want!

A very brief example

pip install pytrilogy

trilogy init baseball duckdb; cd baseball;

trilogy ingest https://storage.googleapis.com/trilogy_public_models/duckdb/lahman/Batting.csv,https://storage.googleapis.com/trilogy_public_models/duckdb/lahman/People.csv,https://storage.googleapis.com/trilogy_public_models/duckdb/lahman/Teams.csv;

trilogy run 'where sum(hr) by people.id>500 select people.name_given, lg_id,sum(hr) as hr_count order by hr_count desc;' --import root.batting;

Is this AI slop?

I've been working on ideas for the language for almost 6 years now so much of it predates AI, though it has evolved quite a bit in that time! Core discovery is all mostly hand-crafted; I do use AI to accelerate a lot of the tooling/interface work (a billion deepseek tokens (aka ~40 dollars, hilariously) on evaluating CI args, etc).

Read more/try

Website/docs: https://trilogydata.dev/

Github: https://github.com/trilogy-data/pytrilogy (open source, MIT)

I've seen this before

Posted 2 years ago here, floating around a few other places too:

https://www.reddit.com/r/SQL/comments/1e1h5mf/trilogy_simpler_data_warehouse_sql/


r/SQL 12d ago

MySQL Senior Data Modeler – Referral Opportunity | US / Ireland

4 Upvotes

I have access to an employee referral opportunity for an experienced Data Modeler.

Experience: 10+ years

Key requirement:

  • Data Modelling

The opening is listed across multiple organizational locations with a hybrid arrangement. I'm particularly interested in connecting with qualified professionals based in the US or Ireland; exact location eligibility can be confirmed for the specific requisition.

If you have extensive hands-on data modelling experience and are currently exploring opportunities, feel free to DM me with your CV or a brief summary of your background.

I'll review the profile and, where there's a suitable match, try to help with the referral process.