SELECT
  model,
  ld.fcst_init_beg,
  ld.fcst_valid_beg,
  ld.fcst_lead,
  fcst_lev,
  obtype,
  vx_mask,
'BOWEN' fcst_var,
  'ME' stat_name,
  IF(ld.me=-9999,'NA',ld.me ) stat_value,
  IF(ld.me_ncl=-9999,'NA',ld.me_ncl  ) stat_ncl,
  IF(ld.me_ncu=-9999,'NA',ld.me_ncu  ) stat_ncu,
  IF(ld.me_bcl=-9999,'NA',ld.me_bcl) stat_bcl,
  IF(ld.me_bcu=-9999,'NA',ld.me_bcu ) stat_bcu
FROM
  stat_header h,
  line_data_cnt ld
WHERE
    BINARY h.fcst_lev IN ('L0')
  AND   BINARY h.obtype IN ('ADPSFC')
  AND   BINARY h.vx_mask IN ('NY')
  AND   BINARY h.model IN ('hr1.sub', 'hr2.sub')
  AND   BINARY ld.fcst_lead IN ('0', '240000', '480000', '720000', '960000', '1200000', '1440000', '1680000', '1920000', '2160000', '2400000', '2640000', '2880000', '3120000', '3360000', '3600000', '3840000')
  AND   BINARY h.fcst_var = 'BOWEN'
  AND ld.stat_header_id = h.stat_header_id
  AND ld.me != -9999;

