SELECT ref_0.c_vj7i1vxsgs as c0, ref_0.c_e as c2, nth_value( cast(ref_0.c_j20ga as char), 1000) over (partition by ref_0.c_vj7i1vxsgs ) as c3, cast(ref_0.c_f as double) as c5 FROM t_xqspe7yna as ref_0 UNION ALL (SELECT DISTINCT ref_6.c_qsm5jm as c0, ref_6.c_ug8wlcrz as c2, substring_index( cast('i' as char), cast(NULL as char), 3) as c3, ref_6.c_qsm5jm as c5 FROM t_n2 as ref_6 WHERE (8126 < ref_6.c_qsm5jm) ) ;