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
Post a Comment