Reputation: 1195
I'm trying to run the following query. It was working fine until i added the column gpv.i_val
the error i'm receiving is "object gpv does not exist" when clearly it does. I'm assuming this is something simple but can't seem to place my finger on it.
SELECT
gpv.i_val,
gcv.i_pln,
gcv.c_typ_cov,
gcv.d_eff,
gcv.d_eff_pln,
gcv.c_sta,
gcv.d_sta,
gcv.c_mde_bft_fst,
gcv.a_bft_fst,
gcv.c_mde_bft_sec,
gcv.a_bft_sec,
gcv.c_mde_bft_trd,
gcv.a_bft_trd,
gcv.p_cre_hom,
gcv.c_cl_rsk,
gpv.c_val,
gcv.c_pol
FROM Pearl_P.tltc906_gcv gcv,
pearl_p.tltc912_gpv gpv
WHERE gcv.i_pln > 0
AND gcv.i_pln = gpv.i_pln
and gcv.c_pol between 'lac100001' and 'lac100004'
UNION
SELECT
gpv.i_val,
gcv.i_pln,
gcv.c_typ_cov,
gcv.d_eff,
gcv.d_eff_pln,
gcv.c_sta,
gcv.d_sta,
gcv.c_mde_bft_fst,
gcv.a_bft_fst,
gcv.c_mde_bft_sec,
gcv.a_bft_sec,
gcv.c_mde_bft_trd,
gcv.a_bft_trd,
gcv.p_cre_hom,
gcv.c_cl_rsk,
gcv.c_pol,
''
FROM Pearl_P.tltc906_gcv gcv
where NOT EXISTS(
SELECT 1
FROM pearl_p.tltc906_gcv gcv,
pearl_p.tltc912_gpv gpv
WHERE gcv.i_pln > 0
AND gcv.i_pln = gpv.i_pln
)
Upvotes: 0
Views: 105
Reputation: 18808
Your second select in the UNION references GPV, but the table itself is not included?
SELECT gpv.i_val,
....
....
''
FROM Pearl_P.tltc906_gcv gcv
WHERE ....
Upvotes: 0
Reputation: 13157
gpv does not exist in your unioned query. you're first select item in that unioned query is gpv.i_val. That's the problem.
Upvotes: 1
Reputation: 1075
gpv is not in the from clause in the second query in the union?
Upvotes: 0