More and more SQL gets written by AI now, inside chat tools, agents and "ask your data" features. Most of it runs. That's the problem: the dangerous mistakes aren't the ones that throw an error. They're the ones that run fine and return a number that looks right.
Below are five of them. Each comes with a tiny Postgres setup you can paste into psql , the query that gets it wrong, the query that gets it right, and the thing you'd have to look at to notice.
Setup (30 seconds)
CREATE DATABASE silent_bugs ; \ c silent_bugs SET TIME ZONE 'UTC' ;
CREATE TABLE orders ( id int PRIMARY KEY , status text , amount numeric , -- list price net_amount numeric , -- after discounts: what finance calls revenue ordered_at timestamptz ) ;
INSERT INTO orders VALUES ( 1001 , 'shipped' , 420 , 400 , '2026-03-15 10:00+00' ) , ( 1002 , 'cancelled' , 300 , 300 , '2026-03-20 12:00+00' ) , ( 1003 , 'shipped' , 480 , 450 , '2026-03-31 23:30 America/New_York' ) , ( 1004 , 'shipped' , 500 , 470 , '2026-04-02 09:00+00' ) ;
CREATE…