Re: [GENERAL] Single Table Select With Aggregate Function

2012-01-03 Thread Rich Shepard
On Wed, 4 Jan 2012, Ondrej Ivanič wrote: window functions might be helpful: http://www.postgresql.org/docs/9.1/static/tutorial-window.html Thanks. I'll carefully read this. Much appreciated, Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your

Re: [GENERAL] Single Table Select With Aggregate Function

2012-01-03 Thread Rich Shepard
On Tue, 3 Jan 2012, Tom Lane wrote: You can do that type of thing using subqueries, eg select ... from mytab where col = (select max(col) from mytab where ...) Thanks, Tom. That's what I thought I needed. or if you don't mind a nonstandard construct, consider SELECT DIST

Re: [GENERAL] Single Table Select With Aggregate Function

2012-01-03 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Rich Shepard Sent: Tuesday, January 03, 2012 6:27 PM To: pgsql-general@postgresql.org Subject: [GENERAL] Single Table Select With Aggregate Function I'm probabl

Re: [GENERAL] Single Table Select With Aggregate Function

2012-01-03 Thread Ondrej Ivanič
Hi, On 4 January 2012 10:26, Rich Shepard wrote: > select max(quant), site, sampdate from chemistry where stream = 'SheepCrk' > and param = 'TDS' group by site, sampdate; > > but this gives me the value of each site and date, not the maximum for all > dates at a specific site. Postgres tells me t

Re: [GENERAL] Single Table Select With Aggregate Function

2012-01-03 Thread Tom Lane
Rich Shepard writes: >What I need to do are three things: >1.) Find the date and site for the maximum value of a specified constituent > on a named stream. >2.) Find the values of that same constituent at other sites on the named > stream on that same date. >3.) Find the date of

[GENERAL] Single Table Select With Aggregate Function

2012-01-03 Thread Rich Shepard
I'm probably not seeing the obvious so I keep making the same mistake. The table holds water chemistry data from multiple streams, sites within each stream, sampling dates, and many chemical constituents. What I need to do are three things: 1.) Find the date and site for the maximum value