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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -