| From: | Vortex <vortex25(at)gmx(dot)de> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | select within aggregate? |
| Date: | 2005-05-06 07:25:35 |
| Message-ID: | 20050506092535.060bca35.vortex25@gmx.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Hi!!
Of course the following is possible in various ways but i wonder
if there is an elegant and simple solution:
A part from apache log:
remote_host varchar(50)
request_uri varchar(50)
ts timestamp with time zone
Now i want to see which host has done how many requests. This
is not difficult:
SELECT remote_host, count(*) FROM apache_log GROUP BY remote_host;
But now i would like to add a column to the result which
shows the most recent requested uri for each group.
This sounds quite easy at first glance but i see no simple solution.
I suppose with max(ts) i could acquire the time of the
most recent request within the group, but how do i get
the corresponding request_uri without doing subquerys or
something like that?
Thank you very much!
Klaus
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ramakrishnan Muralidharan | 2005-05-06 08:04:26 | Re: select within aggregate? |
| Previous Message | Ramakrishnan Muralidharan | 2005-05-06 04:46:50 | Re: Select of a function that returns a array |