title: Query to get all the rows that have the same date with respect to their invoice numbers?
body: <p>I have table from which I have to get invoiceNo, Sum of all the weights, count the number of barcodes and the last value in sum_total from table called selected_items for a particular date.</p>
  
  <pre><code>    SELECT invoiceNo, SUM(weight), COUNT(barcode), sum_total
  FROM selected_items
  WHERE date LIKE '07-Jan-2016' GROUP BY invoiceNo ORDER BY id DESC;
  </code></pre>
  
  <p>This is what my database looks like.
  <a href="https://i.stack.imgur.com/ZxS9o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZxS9o.png" alt="enter image description here"></a></p>
  
  <p>This what I get in output when I run this query in php my admin.
  <a href="https://i.stack.imgur.com/c3gx8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c3gx8.png" alt="enter image description here"></a></p>
  
  <p>What I am wanting to do is get the invoiceNo, sum of weight,count of barcodes and the last value in sum_total for that particular invoiceNo on a certain date.
  In my current query I am getting the sum of weight for 6 items,barcode count as 6 and the first value in sum_total. I have even tried this query but it does not give the expected answer.</p>
  
  <pre><code>SELECT invoiceNo, SUM(weight), COUNT(barcode), sum_total
  FROM selected_items
  WHERE invoiceNo IN ('IN1001','ES102');
  </code></pre>
  
  <p>This is what I am expecting to achieve.<a href="https://i.stack.imgur.com/9Ptz7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Ptz7.png" alt="enter image description here"></a></p>