title: How to use join and group to get highest amount of specific records
body: <p>Models:
  person.rb</p>
  
  <pre><code># Table name: people
  #
  #  id                         :integer          not null, primary key
  #  pesel                      :string           not null
  #  first_name                 :string           not null
  #  last_name                  :string           not null
  </code></pre>
  
  <p>work_schedule.rb</p>
  
  <pre><code># Table name: work_schedules
  #
  #  id          :integer          not null, primary key
  #  start_time  :time             not null
  #  end_time    :time             not null
  #  day_of_week :string           not null
  #  person_id   :integer          not null
  </code></pre>
  
  <p>Associations:
  person.rb</p>
  
  <pre><code>has_many :work_schedules, dependent: :destroy
  </code></pre>
  
  <p>work_schedule.rb</p>
  
  <pre><code>belongs_to :person
  </code></pre>
  
  <p>What I try:</p>
  
  <pre><code>@day_most_work = WorkSchedule.includes(:person).group('work_schedules.id, work_schedules.day_of_week').order('COUNT(work_schedules.day_of_week) DESC').first.day_of_week
  </code></pre>
  
  <p>Issue:
  I don't have idea how to create correct query to get day_of_week which most people are associated. E.g. 23 people work on Monday, 54 people work on Friday. Query should return Friday(more employeers than on Monday). I think my query is incorrect because if 
  I change DESC to ASC return same day(in my case Monday). Most working day cannot be the least working day in same time. This query I create in action of controller.</p>