Hi,
You can try the subquery option.
write select as below -
select key_field1 key_field2 key_filed3 max(date) max(time) field4 from <table name>
into corresponding fields of table <tablename>
where key_field1 in ( select key_field1 where key_field1 in s_key_field1)
and key_field2 in ( select key_field2 where key_field1 in s_key_field2).
Assumptions : Only one unique combination of key_field1 and key_field2 will exist as shown by your data sample.
Also i have denoted the input values via select options s_key_field1 and s_key_field2. The aggregation function works with Date and Time type fields.
BR.