How to sample records

From: Vittorio <vdemart1(at)tin(dot)it>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How to sample records
Date: 2006-07-07 11:22:51
Message-ID: 10c48b9cd00.vdemart1@tin.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear friends, I'm resending my

Dear friends,
owing to a very poor
webmail I'm compelled to use I'm resending my messed-up message of
yesterday.

in postgresql 8.0.7 I have the following table

\d
basedati
Tabella "public.basedati"
Colonna
| Tipo | Modificatori
----------
+-----------------------------+--------------
data_ora | timestamp
without time zone |
cod_wmo | character(5) |
t_aria
| numeric(5,1) |
ur | integer
|

looking like:

data_ora | cod_wmo | t_aria | ur
---------------------+---------+--------+----
2006-07-05 00:50:00 |
16235 | 22.0 | 74
2006-07-05 02:50:00 | 16235 | 19.0 | 80

2006-07-05 09:50:00 | 16235 | 28.0 | 45
2006-07-05 12:00:00 |
16235 | 31.0 | 41
2006-07-06 00:00:00 | 16235 | 20.1 | 93

2006-07-06 00:50:00 | 16235 | 20.0 | 93
2006-07-06 06:50:00 |
16235 | 25.0 | 65
2006-07-06 11:50:00 | 16235 | 30.0 | 49

2006-07-06 12:00:00 | 16235 | 29.5 | 51
2006-07-05 03:00:00 |
16242 | 19.9 | 64
2006-07-05 03:15:00 | 16242 | 20.0 | 69

2006-07-05 10:15:00 | 16242 | 28.0 | 39
2006-07-05 12:00:00 |
16242 | 28.6 | 39
2006-07-06 00:00:00 | 16242 | 22.2 | 71

2006-07-06 00:15:00 | 16242 | 22.0 | 74
2006-07-06 00:45:00 |
16242 | 23.0 | 64
2006-07-06 01:15:00 | 16242 | 21.0 | 74

2006-07-06 10:15:00 | 16242 | 27.0 | 56
2006-07-06 12:00:00 |
16242 | 25.6 | 72

What I would like to extract (and I'm unable
to!!) is:

for each cod_wmo and each day (that is to_char(data_ora,
'YYYY-MM-
DD')), the complete record in correspondence of the maximum
of t_aria.
e.g.
data_ora | cod_wmo | t_aria | ur
---------------------+---------+--------+----
2006-07-05 12:00:00 |
16235 | 31.0 | 41
2006-07-06 11:50:00 | 16235 | 30.0 | 49

2006-07-05 12:00:00 | 16242 | 28.6 | 39
2006-07-06 10:15:00 |
16242 | 27.0 | 56

Please help this absolute beginner

Ciao
Vittorio

Browse pgsql-general by date

  From Date Subject
Next Message badlydrawnbhoy 2006-07-07 11:29:51 How to optimize query that concatenates strings?
Previous Message Tino Wildenhain 2006-07-07 11:18:10 Re: Long term database archival