sql - Count records which has no association or association of association meets condition -


assume have 3 classes:

class person   belongs_to :group end  class group   has_many :people   has_many :tags end  class tag   belongs_to :group end 

it possible, person may have group_id = null.

what need, count person records has group_id = null or group doesn't have tag record attribute status in ('active', 'finished')

one more thing, has fast possible. querying on milions of records.

ideas? thanks.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -