"OizOne" <rautaon@nic.fi> writes:
> I would need to create a query that selects each hostname only once with
> username that has the latest timestamp in the logontime column.
SELECT DISTINCT ON is a convenient way to do this. See the "weather
reports" example in the SELECT reference page for a similar case.
regards, tom lane