sql - Select count(*) doesn't return rows which have the results of 0 in SQLite? -
here sample table:
a | column1 | column2 1 5 8 1 3 2 2 6 9 2 2 5 3 1 3
here query:
select a,count(*) c mytable column1 > 3 group
the result should be:
a | c 1 1 2 1 3 0
but gave me result excluded 0 rows:
a | c 1 1 2 1
i want include rows don't meet condition in clause.
could achieve that?
the where
clause causes a = 3
not on list because filter rows before aggregation of records.
select a, count(case when column1 > 3 1 end) totalcount mytable group
output
╔═══╦════════════╗ ║ ║ totalcount ║ ╠═══╬════════════╣ ║ 1 ║ 1 ║ ║ 2 ║ 1 ║ ║ 3 ║ 0 ║ ╚═══╩════════════╝
Comments
Post a Comment