Use subselect to count rows