SELECT
  model,
  ld.fcst_init_beg,
  ld.fcst_valid_beg,
  ld.fcst_lead,
'DPT' fcst_var,
  'MAE' stat_name,
  IF(ld.mae=-9999,'NA',ld.mae ) stat_value,
  'NA' stat_ncl,
  'NA' stat_ncu,
  IF(ld.mae_bcl=-9999,'NA',ld.mae_bcl) stat_bcl,
  IF(ld.mae_bcu=-9999,'NA',ld.mae_bcu ) stat_bcu
FROM
  stat_header h,
  line_data_cnt ld
WHERE
    BINARY h.model IN ('WRF_E1D', 'WRF_E2D', 'WRF_E3D', 'WRF_G1D', 'WRF_G2D', 'WRF_G3D', 'cosmo')
  AND   BINARY ld.fcst_lead IN ('0', '30000', '60000', '90000', '120000', '150000', '180000', '210000', '240000')
  AND   BINARY h.fcst_var = 'DPT'
  AND ld.stat_header_id = h.stat_header_id
  AND ld.mae != -9999;

