SELECT
  DATE_FORMAT(:starttime, '%Y-%m-%d %H:%i') AS StartTimestamp,
  DATE_FORMAT(:endtime,   '%Y-%m-%d %H:%i') AS EndTimestamp,

  -- Total is now the sum of Merge, Transport, and Sorter counts
  (COALESCE(c.MergeCount,0) + COALESCE(c.TransportCount,0) + COALESCE(c.SorterCount,0)) AS Total,

  -- New individual metrics
  COALESCE(c.MergeCount,0) AS Merge_MCM01,
  COALESCE(c.TransportCount,0) AS Transport_MCM01,
  COALESCE(c.SorterCount,0) AS Sorter_MCM02

FROM (SELECT 1) AS p
LEFT JOIN (
  SELECT
    -- New metric: Merge_MCM01
    SUM(Merge_MCM01 = 1) AS MergeCount,
    -- New metric: Transport_MCM01
    SUM(Transport_MCM01 = 1) AS TransportCount,
    -- Kept metric: Sorter_MCM02
    SUM(Sorter_MCM02 = 1) AS SorterCount
  FROM jam_area
  WHERE t_stamp BETWEEN :starttime AND :endtime
) AS c ON 1=1;