SQL statement help needed
Posted on 2012-08-23
in the below Access SQL code I'm doing a "Where" against c_o after the final_table is generated.
But for that purpose, I'm inserting column c_o in final_table.
How can I change the code so that the column c_o is not inserted in final_table, but still a "Where" can be perfomed on qry1.c_o
I basically don't want to change the table structure of final_table where c_o is not in the first place.
PS: qry1 creates inserts in to final_table
INSERT INTO final_table ( sk, cfk, cfk_up, el_In, C_M, u_c, c_o )
SELECT DISTINCT first_table.sk, first_table.cfk, first_table.cfk_up, first_table.p_el_In,
IIf(Len(Trim([c_num]))>2,IIf(Trim([c_num])="abc","N/A",[c_num]),"No") AS C_M, IIf([r_c]="Y","Y","N") AS u_c, [qry1].c_o AS qry1
FROM (first_table LEFT JOIN qry1 ON first_table.cfk_up = [qry1].fk_e) LEFT JOIN el_rg ON first_table.cfk_up = el_rg.fk_e