SELECT
  model,
  ld.fcst_init_beg,
  ld.fcst_valid_beg,
  ld.fcst_lead,
  HOUR(fcst_valid_beg) valid_hour,
'T2' fcst_var,
  'BCMSE' stat_name,
  IF(ld.bcmse=-9999,'NA',ld.bcmse ) stat_value,
  'NA' stat_ncl,
  'NA' stat_ncu,
  IF(ld.bcmse_bcl=-9999,'NA',ld.bcmse_bcl) stat_bcl,
  IF(ld.bcmse_bcu=-9999,'NA',ld.bcmse_bcu ) stat_bcu
FROM
  stat_header h,
  line_data_cnt ld
WHERE
    BINARY h.model IN ('AI_run1')
  AND HOUR(ld.fcst_valid_beg) IN ('00', '03', '06', '09', '12', '18', '21')
  AND   BINARY h.fcst_var = 'T2'
  AND ld.stat_header_id = h.stat_header_id
  AND ld.bcmse != -9999;

