Revert "Use sub query instead of join. Simple join return rows with repeats ID's, since for one ID from FLOWS table there are several FLOW_ID in EVENTS. Need to use subquery with DISTINCT statement."

This reverts commit 6280e60f6a8b9e5ed9e0dbc9b4e91fc555dc04c8.
Revert "Add filter to Derby query for paging"

This reverts commit 1505423b3ece9dcece409edaa96d610240062dbb.