sqlstreak

SQL error

argument of WHERE must be type boolean, not type numeric

Updated · Tested on PostgreSQL 18.6 and SQLite 3.54.1 (results generated , re-checked on every release)

Short answer

PostgreSQL wants a true-or-false condition after WHERE, AND and OR. WHERE price isn't one; compare the value: WHERE price > 10, WHERE price IS NOT NULL.

The exact messages

  • PostgreSQLERROR: argument of WHERE must be type boolean, not type numeric
  • SQLiteNo error, but a silent surprise: see below.

How to read this message

This is what PostgreSQL 18.6 prints for the broken query below, the way psql shows it. LINE gives the line it was reading when it gave up, and the ^ marks the exact spot.

ERROR:  argument of WHERE must be type boolean, not type numeric
LINE 3: WHERE price;
              ^

Why it happens

A missing comparison

WHERE price or WHERE name on its own, often after editing a condition and deleting half of it.

A 1/0 flag column

Integer flags (is_active) act as booleans in SQLite. In PostgreSQL compare them: WHERE is_active = 1, or make the column BOOLEAN.

Reproduce it, then fix it

Both queries run on a real database in your browser. Switch dialects to compare.

Broken
SELECT name, price
FROM menu_items
WHERE price;
Fixed
SELECT name, price
FROM menu_items
WHERE price > 10;

A comparison gives true or false for each row, which is what WHERE needs.

The fix returns, PostgreSQL: 5 rows

nameprice
Margherita11
Pepperoni Rocket13.5
Four Cheese Orbit14
BBQ Meteor15.5
Veggie Nebula13

The fix returns, SQLite: 5 rows

nameprice
Margherita11
Pepperoni Rocket13.5
Four Cheese Orbit14
BBQ Meteor15.5
Veggie Nebula13

Experiment with it: PostgreSQL playground·SQLite playground

Other forms of this mistake

Each one was run when this page was built; the result is what the engine really does.

  • SELECT name FROM menu_items WHERE vegetarian AND price;

    PostgreSQLERROR: argument of AND must be type boolean, not type numeric

    The same check applies to each side of AND and OR. vegetarian is a BOOLEAN column, so it's fine on its own; price isn't.

What SQLite does instead

SQLite treats any non-zero number as true, so WHERE price keeps every row whose price isn't 0 or NULL. It looks like it works, which is why the bug survives until the query meets PostgreSQL.

Official documentation

Stop hitting this error

Practise the concept behind it in a five-minute lesson, or read the full guide: SQL WHERE clause: filtering rows.