Skip to content

Tag: count

Counting number of joined rows in left join

I’m trying to write an aggregate query in SQL which returns the count of all records joined to a given record in a table; If no records were joined to the given record, then the result for that record should be 0: Data My database looks like this (I’m not able to change the structure, unfortunatel…

H2 Get row count for all tables

I would like to know the total number of rows for each table. And that for all tables at once. Is this possible with H2? I’m thinking of a table: |table name | row size | At the moment I’m using the current version 1.3.170 (2012-11-30). Answer You would need to use a user-defined function, for exa…

MySQL: Count the distinct rows per day

I have an interesting query I need to do. I have a table with an INT column containing ip address numbers (using INET_ATON), and a timestamp column. I want to be able to count the number of unique ip address columns there are per day. That is, how many distinct ip rows there are in each day. So, for example,