title: Dividing and counting the booking status in columns
body: <p>I am trying to create a breakdown of the status of the booking of our clients. The query works but each column shows the same number. I added a picture to show the result.</p>
  <pre><code>select distinct client.id,
  
  client.company_name, 
  
  count(CASE WHEN booking.status = 'ok' THEN 1 ELSE 0 END) as &quot;confirmed&quot;,
  count(CASE WHEN booking.status = 'CA' THEN 1 ELSE 0 END) as &quot;cancelled&quot; ,
  count(CASE WHEN booking.status = 'BU' THEN 1 ELSE 0 END) as &quot;BU&quot; 
  
  from client
  
  join auth_user on auth_user.id = client.user_id 
  join booking on booking.client_id = client.id
  
  where auth_user.date_joined &gt;= '04-01-2021'
  
  group by 1, 2
  </code></pre>
  <p><a href="https://i.stack.imgur.com/lH1Xn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lH1Xn.jpg" alt="enter image description here" /></a></p>