SELECT
  model,
  ld.fcst_init_beg,
  ld.fcst_valid_beg,
  ld.fcst_lead,
'APCP_01' fcst_var,
  'NBR_FBS' stat_name,
  IF(ld.fbs=-9999,'NA',ld.fbs ) stat_value,
  'NA' stat_ncl,
  'NA' stat_ncu,
  IF(ld.fbs_bcl=-9999,'NA',ld.fbs_bcl) stat_bcl,
  IF(ld.fbs_bcu=-9999,'NA',ld.fbs_bcu ) stat_bcu
FROM
  stat_header h,
  line_data_nbrcnt ld
WHERE
    BINARY h.model IN ('core01_hwt')
  AND   BINARY ld.fcst_lead IN ('10000', '20000', '30000', '40000')
  AND   BINARY h.fcst_var = 'APCP_01'
  AND ld.stat_header_id = h.stat_header_id
  AND ld.fbs != -9999;

