Skip site navigation (1) Skip section navigation (2)

VIEWs with aggregate functions

From: Paul Makepeace <postgresql(dot)org(at)paulm(dot)com>
To: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: VIEWs with aggregate functions
Date: 2004-10-13 22:39:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I'm probably missing something obvious here but I can't quite see it.

  CREATE VIEW weekly_bar_info AS
     SELECT bar_name,
            MIN(bar_date) AS earliest_date, MAX(bar_date) AS latest_date,
            MIN(bar) as min_bar, MAX(bar) as max_bar
       FROM bar_data
      WHERE valid_weekly='t'
   GROUP BY bar_name

What I'd like to be able do is WHERE bar_name = ? AND bar_date >= ?
i.e. select over a date range but that isn't directly possible with the
VIEW as is.

Is there some way of achieving this?

(The reason for the view is that that set of aggregate functions is
appearing a few times in related queries, and that perl's Class::DBI is
less of a headache with VIEWs.)


Paul Makepeace ..............................

"If they asked us nicely, then we wouldnt be as happy with it."


pgsql-novice by date

Next:From: Ron St-PierreDate: 2004-10-13 23:01:13
Subject: Re: VIEWs with aggregate functions
Previous:From: Jake StrideDate: 2004-10-13 21:02:21
Subject: Re: Data Grid

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group