I'm needing to find when an order is on time. The issue is some orders can have items that are considered on time while other items are not. I need to find when the whole order is on time.
select order_no, item_id, CASE WHEN (DATEDIFF(dd, dateadd(day,1, requested_date), ship_date)) <= 0 THEN '1' END AS item_on_time
GROUP BY order_no, item_id, requested_date, ship_date
So below is what I'm needing which would be column D