Search Postgresql Archives

Selecting All Columns Associated With Maximum Value of One Column

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

 



  A table (chemistry) has columns named site_id, sample_date, param, quant,
and str_name (among other columns). I want to find the site_id, sample_date,
and quant for a specific str_name and param. I cannot get the proper syntax
in the SELECT statement.

  My attempts are variations of,

SELECT max(quant), param, site_id, sample_date, str_name from chemistry
WHERE param = 'TDS' AND str_name = 'BurrowCrk';

which prompts postgres to tell me,

ERROR:  column "chemistry.param" must appear in the GROUP BY clause or be
used in an aggregate function

  I suspect that retrieving these data requires nested SELECT statements,
and I'd appreciate learning how to retrive such data.

Rich


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[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