SELECT
   fcst_valid_beg,
  ld.fcst_init_beg,
  ld.fcst_lead,
'TMP' fcst_var,
  'RMSE' stat_name,
  IF(ld.rmse=-9999,'NA',ld.rmse ) stat_value,
  'NA' stat_ncl,
  'NA' stat_ncu,
  IF(ld.rmse_bcl=-9999,'NA',ld.rmse_bcl) stat_bcl,
  IF(ld.rmse_bcu=-9999,'NA',ld.rmse_bcu ) stat_bcu
FROM
  stat_header h,
  line_data_cnt ld
WHERE
    BINARY ld.fcst_valid_beg IN ()
  AND   BINARY ld.fcst_lead IN ('0', '10000', '20000', '30000', '40000', '50000', '60000', '70000', '80000', '90000', '100000', '110000', '120000')
  AND   BINARY h.fcst_var = 'TMP'
  AND ld.stat_header_id = h.stat_header_id
  AND ld.rmse != -9999;

