count-star
What it does
Section titled “What it does”Reports a COUNT of the constant 1 or 0, as in COUNT(1).
Why it matters
Section titled “Why it matters”COUNT(*) is the standard form and counts rows. COUNT(1) and COUNT(0) give the same number, but a reader may wonder whether the constant matters, and some think it is faster, which it is not.
To fix, write COUNT(*).
Example
Section titled “Example”...select 1 union all select 2;select 1 union distinct select 2;...select count(1), count(0), count(*), count(a) from t;...select a from t left join u on t.a = u.a;...Configuration
Section titled “Configuration”sql: lint: rules: count-star: warn # off (default), warn, errorEnabled by the presets: sql/sqlfluff.
Suppress one line with sudsy-disable-next-line count-star in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| sqlfluff | CV04 |
full |