SQL

SQL

Made by DeepSource

Use of non-ANSI spec syntax for COUNT all rows SQL-L047

Style
Minor

Use consistent syntax to express “count number of rows”.

COUNT(*), COUNT(1), and even COUNT(0) are equivalent syntaxes in many SQL engines due to optimizers interpreting these instructions as “count number of rows in result”.

The ANSI-92 spec mentions the COUNT(*) syntax specifically as having a special meaning:

If COUNT(*) is specified, then the result is the cardinality of T.

Bad practice

SELECT
    count(1)
FROM table_a

Recommended

SELECT
    count(*)
FROM table_a