Unix Technical Forum

How to sample records

This is a discussion on How to sample records within the Pgsql General forums, part of the PostgreSQL category; --> Dear friends, I'm resending my Dear friends, owing to a very poor webmail I'm compelled to use I'm resending ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 10:31 AM
Vittorio
 
Posts: n/a
Default How to sample records

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




---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:02 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com