title: Query to get only one row from multiple rows having same values
body: <p>I have a notification table as follows</p>
  
  <pre><code>|id|user_receiver|user_sender|post_id|action|date|is_read
  </code></pre>
  
  <p>here <code>user_sender</code> is the person who generated notification, <code>user_receiver</code> is one who got the notification, <code>post_id</code> is id of post, <code>action</code> can be like, comment etc, <code>is_read</code> is 1 if its read by receiver else 0</p>
  
  <p>I want to get all notifications for loggedin user</p>
  
  <p>query that I am using is</p>
  
  <pre><code>SELECT id, user_receiver, user_sender, post_id, action, 
   max(date) as date, is_read 
  FROM notification 
  WHERE user_receiver=$ses_user 
  group by user_sender, action,post_id,is_read 
  order by date desc
  </code></pre>
  
  <p>but it doesn't give me latest rows even though I am using <code>max(date)</code> and I also want to get number of notifications that are unread.</p>
  
  <p>I want only one row if there are multiple rows having same post_id, user_sender and action together and that should be the latest one. For example a user likes a post, a row is added to the table, then user dislikes and likes again, then a new row is added again, I want only the new row only.</p>