title: Find out extra quantity available in a table
body: <p>I have two tables, let's say OrderPlaced and OrderDelivered.</p>
  <p>The OrderPlaced table looks like this:<br />
  <a href="https://i.stack.imgur.com/vvH8O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vvH8O.png" alt="OrderPlaced" /></a></p>
  <p>In a single order we can have multiple products(which is defined by sku in the table) and each product can have multiple quantity.</p>
  <p>The OrderDelivered table looks like this:<br />
  <a href="https://i.stack.imgur.com/BdqCZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BdqCZ.png" alt="OrderDelivered" /></a></p>
  <p>So technically 3 products have not been delivered. Orderid 1000 - product S101, Orderid 1001 - product S102(as 3 quantity required, but 2 delivered) and Orderid 1002 - product S100.</p>
  <p>I am trying to write a SQL query that can give me the OrderId and sku those have not been delivered. For now I have written something like</p>
  <pre><code>select OrderPlaced.orderid,OrderPlaced.sku
  from OrderPlaced 
  left join OrderDelivered
    on OrderPlaced.Orderid = OrderDelivered.orderid and OrderPlaced.sku = OrderDelivered.sku
  where OrderDelivered.sku is NULL;
  </code></pre>
  <p>This is giving me Orderid 1000 - product S101 and Orderid 1002 - product S100, but Orderid 1001 - product S102 is missing. I understand I have to do a check on qty as well, but couldn't think how to do that. I would really appreciate it if someone can help me with that part.</p>