/* During cleanup or testing, it occasionally happens that we get multiple
entries corresponding to the same log. The following query provides a
convenient way to look at them, for manual cleanup. */

	-- How often was that log found in total?
select howoften,
	-- How many rows correspond to that setup_id?
	(select count(*) from rawdata where rawdata.setup_id = setup.setup_id) howmany,
	-- General info
	setup_id, logging_start_time, distance, duration, upload_time
from setup
-- Subtable to count how many times each logging start time occurs
join (select count(*) howoften, logging_start_time starttime
	from setup
	group by logging_start_time
	-- Logs occuring only once aren't interesting to us here
	having count(*) > 1
	) overlogged
on logging_start_time = starttime
-- To make it visually easier to compare the ones belonging together
order by logging_start_time;
