Hallo Forum,
ich habe wieder mal ein Verständnisproblem.
Ich habe mehrere Tabellen tmd = Artikel, tmh = Artikel-Historie, tu = Benutzer und tpd = Benutzerdaten.
Jeder Artikel hat eine part_id - part_version z.B. 0815 - A, 0815 - B, 0815 - C....
zu der dieser Artikelversionen 0815 - A, 0815 - B, 0815 - C gibt es diverse Historien-Einträge.
Die Historieneinträge sind mit Transition benannt und haben ein Datum.
Ich möchte pro Artikel-Version aus den Historieneinträgen nur die Transition mit dem aktuellesten Datum
auslesen.
Egal was ich versuche, ich scheitere entweder daran, dass ich zuviele Einträge bekomme oder ich bekomme aus den z.b. 3 Artikelversionen eine Willkürliche
Wo liegt den hier mein Gedanken Fehler?
Danke und Gruß
Stephan
ich habe wieder mal ein Verständnisproblem.
Ich habe mehrere Tabellen tmd = Artikel, tmh = Artikel-Historie, tu = Benutzer und tpd = Benutzerdaten.
Jeder Artikel hat eine part_id - part_version z.B. 0815 - A, 0815 - B, 0815 - C....
zu der dieser Artikelversionen 0815 - A, 0815 - B, 0815 - C gibt es diverse Historien-Einträge.
Die Historieneinträge sind mit Transition benannt und haben ein Datum.
Ich möchte pro Artikel-Version aus den Historieneinträgen nur die Transition mit dem aktuellesten Datum
auslesen.
Code:
select tmd.part_id, tmd.part_version, tmd.pse_konstr, tmd.c_uic, tu.c_name, tu.c_ic, tpd.s_user, tpd.s_first_name, tmh.function, tmh.memo_ger, tmh.change_status, tmh.modify_name, tmh.modify_date from t_master_dat tmd, t_master_his tmh, t_user tu, t_prs_dat tpd where tmd.c_uic = tu.c_ic and tu.c_ic = tpd.c_ic(+) and (tmd.c_id = tmh.c_id_1 and tmh.function = 'TRANSITION') order by tmd.part_id asc, tmd.part_version asc, tmh.modify_date;
Code:
select tmd.part_id, tmd.part_version, tmd.pse_konstr, tmd.c_uic, tu.c_name, tu.c_ic, tpd.s_user, tpd.s_first_name, tmh.function, tmh.memo_ger, tmh.change_status, tmh.modify_name, tmh.modify_date from t_master_dat tmd, t_master_his tmh, t_user tu, t_prs_dat tpd where tmd.part_id = '100142' and tmd.c_uic = tu.c_ic(+) and tu.c_ic = tpd.c_ic(+) and tmd.c_id = tmh.c_id_1 and tmh.function = 'TRANSITION' and tmh.modify_date = (select max(tmh.modify_date) from t_master_dat tmd, t_master_his tmh where tmd.part_id = '100142' and tmd.c_id = tmh.c_id_1 and tmh.function = 'TRANSITION') order by tmh.modify_date desc;
Danke und Gruß
Stephan
Comment