SELECT
    object_id, ra, dec,
    g_apertureflux_10_flux,
    g_apertureflux_10_fluxsigma,
    g_apertureflux_10_mag,
    g_apertureflux_10_magsigma,
    g_apertureflux_10_flag,
    g_apertureflux_15_flux,
    g_apertureflux_15_fluxsigma,
    g_apertureflux_15_mag,
    g_apertureflux_15_magsigma,
    g_apertureflux_15_flag,
    g_apertureflux_20_flux,
    g_apertureflux_20_fluxsigma,
    g_apertureflux_20_mag,
    g_apertureflux_20_magsigma,
    g_apertureflux_20_flag,
    g_apertureflux_30_flux,
    g_apertureflux_30_fluxsigma,
    g_apertureflux_30_mag,
    g_apertureflux_30_magsigma,
    g_apertureflux_30_flag,
    g_apertureflux_40_flux,
    g_apertureflux_40_fluxsigma,
    g_apertureflux_40_mag,
    g_apertureflux_40_magsigma,
    g_apertureflux_40_flag,
    g_apertureflux_57_flux,
    g_apertureflux_57_fluxsigma,
    g_apertureflux_57_mag,
    g_apertureflux_57_magsigma,
    g_apertureflux_57_flag,
    g_apertureflux_84_flux,
    g_apertureflux_84_fluxsigma,
    g_apertureflux_84_mag,
    g_apertureflux_84_magsigma,
    g_apertureflux_84_flag,
    g_kronflux_flux,
    g_kronflux_fluxsigma,
    g_kronflux_mag,
    g_kronflux_magsigma,
    g_extendedness_value,
    r_apertureflux_10_flux,
    r_apertureflux_10_fluxsigma,
    r_apertureflux_10_mag,
    r_apertureflux_10_magsigma,
    r_apertureflux_10_flag,
    r_apertureflux_15_flux,
    r_apertureflux_15_fluxsigma,
    r_apertureflux_15_mag,
    r_apertureflux_15_magsigma,
    r_apertureflux_15_flag,
    r_apertureflux_20_flux,
    r_apertureflux_20_fluxsigma,
    r_apertureflux_20_mag,
    r_apertureflux_20_magsigma,
    r_apertureflux_20_flag,
    r_apertureflux_30_flux,
    r_apertureflux_30_fluxsigma,
    r_apertureflux_30_mag,
    r_apertureflux_30_magsigma,
    r_apertureflux_30_flag,
    r_apertureflux_40_flux,
    r_apertureflux_40_fluxsigma,
    r_apertureflux_40_mag,
    r_apertureflux_40_magsigma,
    r_apertureflux_40_flag,
    r_apertureflux_57_flux,
    r_apertureflux_57_fluxsigma,
    r_apertureflux_57_mag,
    r_apertureflux_57_magsigma,
    r_apertureflux_57_flag,
    r_apertureflux_84_flux,
    r_apertureflux_84_fluxsigma,
    r_apertureflux_84_mag,
    r_apertureflux_84_magsigma,
    r_apertureflux_84_flag,
    r_kronflux_flux,
    r_kronflux_fluxsigma,
    r_kronflux_mag,
    r_kronflux_magsigma,
    r_extendedness_value,
    i_apertureflux_10_flux,
    i_apertureflux_10_fluxsigma,
    i_apertureflux_10_mag,
    i_apertureflux_10_magsigma,
    i_apertureflux_10_flag,
    i_apertureflux_15_flux,
    i_apertureflux_15_fluxsigma,
    i_apertureflux_15_mag,
    i_apertureflux_15_magsigma,
    i_apertureflux_15_flag,
    i_apertureflux_20_flux,
    i_apertureflux_20_fluxsigma,
    i_apertureflux_20_mag,
    i_apertureflux_20_magsigma,
    i_apertureflux_20_flag,
    i_apertureflux_30_flux,
    i_apertureflux_30_fluxsigma,
    i_apertureflux_30_mag,
    i_apertureflux_30_magsigma,
    i_apertureflux_30_flag,
    i_apertureflux_40_flux,
    i_apertureflux_40_fluxsigma,
    i_apertureflux_40_mag,
    i_apertureflux_40_magsigma,
    i_apertureflux_40_flag,
    i_apertureflux_57_flux,
    i_apertureflux_57_fluxsigma,
    i_apertureflux_57_mag,
    i_apertureflux_57_magsigma,
    i_apertureflux_57_flag,
    i_apertureflux_84_flux,
    i_apertureflux_84_fluxsigma,
    i_apertureflux_84_mag,
    i_apertureflux_84_magsigma,
    i_apertureflux_84_flag,
    i_kronflux_flux,
    i_kronflux_fluxsigma,
    i_kronflux_mag,
    i_kronflux_magsigma,
    i_extendedness_value,
    z_apertureflux_10_flux,
    z_apertureflux_10_fluxsigma,
    z_apertureflux_10_mag,
    z_apertureflux_10_magsigma,
    z_apertureflux_10_flag,
    z_apertureflux_15_flux,
    z_apertureflux_15_fluxsigma,
    z_apertureflux_15_mag,
    z_apertureflux_15_magsigma,
    z_apertureflux_15_flag,
    z_apertureflux_20_flux,
    z_apertureflux_20_fluxsigma,
    z_apertureflux_20_mag,
    z_apertureflux_20_magsigma,
    z_apertureflux_20_flag,
    z_apertureflux_30_flux,
    z_apertureflux_30_fluxsigma,
    z_apertureflux_30_mag,
    z_apertureflux_30_magsigma,
    z_apertureflux_30_flag,
    z_apertureflux_40_flux,
    z_apertureflux_40_fluxsigma,
    z_apertureflux_40_mag,
    z_apertureflux_40_magsigma,
    z_apertureflux_40_flag,
    z_apertureflux_57_flux,
    z_apertureflux_57_fluxsigma,
    z_apertureflux_57_mag,
    z_apertureflux_57_magsigma,
    z_apertureflux_57_flag,
    z_apertureflux_84_flux,
    z_apertureflux_84_fluxsigma,
    z_apertureflux_84_mag,
    z_apertureflux_84_magsigma,
    z_apertureflux_84_flag,
    z_kronflux_flux,
    z_kronflux_fluxsigma,
    z_kronflux_mag,
    z_kronflux_magsigma,
    z_extendedness_value,
    y_apertureflux_10_flux,
    y_apertureflux_10_fluxsigma,
    y_apertureflux_10_mag,
    y_apertureflux_10_magsigma,
    y_apertureflux_10_flag,
    y_apertureflux_15_flux,
    y_apertureflux_15_fluxsigma,
    y_apertureflux_15_mag,
    y_apertureflux_15_magsigma,
    y_apertureflux_15_flag,
    y_apertureflux_20_flux,
    y_apertureflux_20_fluxsigma,
    y_apertureflux_20_mag,
    y_apertureflux_20_magsigma,
    y_apertureflux_20_flag,
    y_apertureflux_30_flux,
    y_apertureflux_30_fluxsigma,
    y_apertureflux_30_mag,
    y_apertureflux_30_magsigma,
    y_apertureflux_30_flag,
    y_apertureflux_40_flux,
    y_apertureflux_40_fluxsigma,
    y_apertureflux_40_mag,
    y_apertureflux_40_magsigma,
    y_apertureflux_40_flag,
    y_apertureflux_57_flux,
    y_apertureflux_57_fluxsigma,
    y_apertureflux_57_mag,
    y_apertureflux_57_magsigma,
    y_apertureflux_57_flag,
    y_apertureflux_84_flux,
    y_apertureflux_84_fluxsigma,
    y_apertureflux_84_mag,
    y_apertureflux_84_magsigma,
    y_apertureflux_84_flag,
    y_kronflux_flux,
    y_kronflux_fluxsigma,
    y_kronflux_mag,
    y_kronflux_magsigma,
    y_extendedness_value,
    n387_apertureflux_10_flux,
    n387_apertureflux_10_fluxsigma,
    n387_apertureflux_10_mag,
    n387_apertureflux_10_magsigma,
    n387_apertureflux_10_flag,
    n387_apertureflux_15_flux,
    n387_apertureflux_15_fluxsigma,
    n387_apertureflux_15_mag,
    n387_apertureflux_15_magsigma,
    n387_apertureflux_15_flag,
    n387_apertureflux_20_flux,
    n387_apertureflux_20_fluxsigma,
    n387_apertureflux_20_mag,
    n387_apertureflux_20_magsigma,
    n387_apertureflux_20_flag,
    n387_apertureflux_30_flux,
    n387_apertureflux_30_fluxsigma,
    n387_apertureflux_30_mag,
    n387_apertureflux_30_magsigma,
    n387_apertureflux_30_flag,
    n387_apertureflux_40_flux,
    n387_apertureflux_40_fluxsigma,
    n387_apertureflux_40_mag,
    n387_apertureflux_40_magsigma,
    n387_apertureflux_40_flag,
    n387_apertureflux_57_flux,
    n387_apertureflux_57_fluxsigma,
    n387_apertureflux_57_mag,
    n387_apertureflux_57_magsigma,
    n387_apertureflux_57_flag,
    n387_apertureflux_84_flux,
    n387_apertureflux_84_fluxsigma,
    n387_apertureflux_84_mag,
    n387_apertureflux_84_magsigma,
    n387_apertureflux_84_flag,
    n387_kronflux_flux,
    n387_kronflux_fluxsigma,
    n387_kronflux_mag,
    n387_kronflux_magsigma,
    n387_extendedness_value,
    n816_apertureflux_10_flux,
    n816_apertureflux_10_fluxsigma,
    n816_apertureflux_10_mag,
    n816_apertureflux_10_magsigma,
    n816_apertureflux_10_flag,
    n816_apertureflux_15_flux,
    n816_apertureflux_15_fluxsigma,
    n816_apertureflux_15_mag,
    n816_apertureflux_15_magsigma,
    n816_apertureflux_15_flag,
    n816_apertureflux_20_flux,
    n816_apertureflux_20_fluxsigma,
    n816_apertureflux_20_mag,
    n816_apertureflux_20_magsigma,
    n816_apertureflux_20_flag,
    n816_apertureflux_30_flux,
    n816_apertureflux_30_fluxsigma,
    n816_apertureflux_30_mag,
    n816_apertureflux_30_magsigma,
    n816_apertureflux_30_flag,
    n816_apertureflux_40_flux,
    n816_apertureflux_40_fluxsigma,
    n816_apertureflux_40_mag,
    n816_apertureflux_40_magsigma,
    n816_apertureflux_40_flag,
    n816_apertureflux_57_flux,
    n816_apertureflux_57_fluxsigma,
    n816_apertureflux_57_mag,
    n816_apertureflux_57_magsigma,
    n816_apertureflux_57_flag,
    n816_apertureflux_84_flux,
    n816_apertureflux_84_fluxsigma,
    n816_apertureflux_84_mag,
    n816_apertureflux_84_magsigma,
    n816_apertureflux_84_flag,
    n816_kronflux_flux,
    n816_kronflux_fluxsigma,
    n816_kronflux_mag,
    n816_kronflux_magsigma,
    n816_extendedness_value,
    n921_apertureflux_10_flux,
    n921_apertureflux_10_fluxsigma,
    n921_apertureflux_10_mag,
    n921_apertureflux_10_magsigma,
    n921_apertureflux_10_flag,
    n921_apertureflux_15_flux,
    n921_apertureflux_15_fluxsigma,
    n921_apertureflux_15_mag,
    n921_apertureflux_15_magsigma,
    n921_apertureflux_15_flag,
    n921_apertureflux_20_flux,
    n921_apertureflux_20_fluxsigma,
    n921_apertureflux_20_mag,
    n921_apertureflux_20_magsigma,
    n921_apertureflux_20_flag,
    n921_apertureflux_30_flux,
    n921_apertureflux_30_fluxsigma,
    n921_apertureflux_30_mag,
    n921_apertureflux_30_magsigma,
    n921_apertureflux_30_flag,
    n921_apertureflux_40_flux,
    n921_apertureflux_40_fluxsigma,
    n921_apertureflux_40_mag,
    n921_apertureflux_40_magsigma,
    n921_apertureflux_40_flag,
    n921_apertureflux_57_flux,
    n921_apertureflux_57_fluxsigma,
    n921_apertureflux_57_mag,
    n921_apertureflux_57_magsigma,
    n921_apertureflux_57_flag,
    n921_apertureflux_84_flux,
    n921_apertureflux_84_fluxsigma,
    n921_apertureflux_84_mag,
    n921_apertureflux_84_magsigma,
    n921_apertureflux_84_flag,
    n921_kronflux_flux,
    n921_kronflux_fluxsigma,
    n921_kronflux_mag,
    n921_kronflux_magsigma,
    n921_extendedness_value,
    isprimary

FROM
 

  -- DEEP SURVEY (in PDR1 available in ELAIS-N1, XMM-LSS, E(xtended)-COSMOS, DEEP2-3)
  pdr2_dud.forced
  -- uncomment the survey tier of interest and comment the other
  -- LEFT JOIN pdr1_udeep.afterburner USING(object_id)
  LEFT JOIN pdr2_dud.forced2 USING (object_id)
  LEFT JOIN pdr2_dud.forced3 USING (object_id)
  LEFT JOIN pdr2_dud.forced4 USING (object_id)
  LEFT JOIN pdr2_dud.forced5 USING (object_id)

WHERE
  -- uncomment the field and survey tier of interest and comment the others
  pdr2_dud.search_sxds(object_id)

AND pdr2_dud.forced.isprimary