Search Postgresql Archives

How to sample records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux