title: SQL group by date gang within data range
body: <p>What's the best way to query a table like below in sql?</p>
  
  <p>I need to determine the <code>PackListGrp</code> variable (<code>PICKONLY</code> or <code>JITPICK</code>)  by the <code>expectedshipdate</code>, <code>deliverymethod</code> for a given <code>OrderID</code>.</p>
  
  <p>When the <code>expectedshipdate</code> is within 2 days for each line item then the <code>PackListGrp</code> for would be <code>JITPICK</code>.</p>
  
  <p>When the <code>expectedshipdate</code> is > 2 days, the the Pick <code>DeliveryMethod</code> would be <code>PickOnly</code> and the <code>PSIEST</code> would be <code>JITPICK</code>.</p>
  
  <p>Basically i'm just trying to gang order line items determined by the expectedshipdate.</p>
  
  <p>Thanks</p>
  
  <pre><code>OrderID ExpectedShipDate    Sku     DeliveryMethod  PackListGrp
  66064   13-Sep-18         22-81506  Pick            PickOnly
  66064   13-Sep-18         878-85487 Pick            PickOnly
  66064   13-Sep-18         5-4878-   Pick            PickOnly
  66064   13-Sep-18         3-020-02  Pick            PickOnly
  66064   13-Sep-18         7-209-23  Pick            PickOnly
  66064   13-Sep-18         7-206-05  Pick            PickOnly
  66064   13-Sep-18         7-305-08  Pick            PickOnly
  66064   13-Sep-18         7-567-20  Pick            PickOnly
  66064   18-Sep-18         6-104-24  Pick            JITPICK
  66064   19-Sep-18         TCC_KS    PSIEST          JITPICK
  66064   17-Sep-18         TCF-DK    PSIEST          JITPICK
  </code></pre>