title: advanced SQL query help. need to translate ruby script to SQL query
body: <p>I am pretty new with SQL and i have to translate this ruby script to SQL because the ruby script is taking WAY too long to run on the server. Here is the ruby script:</p>
  
  <pre><code>orders = Order.find_all_by_state("in_progress"); nil
  orders.each do |o|
    if o.line_items.length == 0 and o.created_at &gt; Time.parse("2011-12-14 00:00:00.000000 -08:00") and o.created_at &lt; Time.parse("2011-12-21 00:00:00.000000 -08:00")
      o.adjustments[0].destroy
      o.shipment.destroy
      o.turnaround_time.destroy
      o.checkout.destroy
      o.destroy
    end; nil
  end; nil
  </code></pre>
  
  <p>Anyway, the associations are as follows:</p>
  
  <p>an order has one checkout, shipment, turnaround time, many line_items, and many adjustments (the orders i want to delete only have 1). <strong>I want to delete all orders that have no line items and was created within those range of dates (dec 15th-20th). I also want to delete all objects associated with those orders (shipments, turnaround_times, checkouts, adjustments).</strong> I am new to SQL and i have absolutely no idea how to do this. I've been looking at SQL documentation but i am really struggling with the syntax for this. If i could get some help, that would be great.</p>