Subject little help to build a query in Firebird
Author Tanju Özgür
Hi all,
I've the following query which produces the results (at least s.th visual), but not exactly what i want .
Generators sole purpose is to provide the row numbering for Derived Table "a". Then filling the Elements table "e.prop_type field with a.num field where matching occurs for both table. But after performing the below query prop_type of E table is filled with increased numbers for each row (e.g. 1,2,3 ...17), where it's supposed to be (e.g. 1,1,1,2,2,2,3.......1,1) depending on matching occurences for both tables.
 
set generator gen_new to 0;
merge into elements as e
using (select gen_id(gen_new,1) as num, new_tbl.elm_prof, new_tbl.elm_mat from (select distinct elm_prof , elm_mat from ELEMENTS ) as new_tbl) as a
on (e.elm_prof = a.elm_prof)
when matched then update set e.prop_type = a.num

[Non-text portions of this message have been removed]