Write a SQL query to join staffing schedules, production output, and sales results to identify which shifts are most efficient. Use scheduled labor hours as scheduled hours multiplied by staff count. Treat production output per labor hour as the primary efficiency measure, with sales revenue per labor hour as a supporting metric. Exclude shifts with zero or unknown labor hours.
Output
- One row per eligible shift, including shifts without matching production or sales rows.
- Columns:
shift_id, shift_date, shift_name, labor_hours, units_produced, total_defects, sales_revenue, production_per_labor_hour, sales_per_labor_hour, and efficiency_rank.
- Order by
efficiency_rank, then shift_id.