| From: | "Scott V(dot) McGuire" <svmcguir(at)syr(dot)edu> |
|---|---|
| To: | pgsql-general(at)postgreSQL(dot)org |
| Subject: | Can you get a whole row with a max on one column |
| Date: | 2000-01-27 19:26:10 |
| Message-ID: | 20000127142610.A2849@syr.edu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I have a table with these columns (and more but irrelevant ones)
| magnetic_susceptibility | float8
| spin_coupling | float8
| boundary_coupling | float8
I want a query to give (spin_coupling, boundary_coupling) where for each
boundary_coupling it gives the spin_coupling for which magnetic_susceptibility is
maximum.
Kinda like:
select boundary_coupling, max(magnetic_susceptibility) from run_averages group by
boundary_coupling;
except I don't want to see max(magnetic_susceptibility) but the spin_coupling which
corresponds to max(magnetic_susceptibility).
I know I can do this with a small program, but I would like to have a single query
so that I can use psql -c "query" in a script and pipe the results to a file.
Thanks,
--
Scott V. McGuire <svmcguir(at)syr(dot)edu>
GnuPG key available at http://physics.syr.edu/~svmcguir
GnuPG key fingerprint: 21EA 4999 3620 3E1D 71EC 98A9 5B9B EF52 1258 6D53
GnuPG is at http://www.gnupg.org/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Marten Feldtmann | 2000-01-27 20:14:46 | Re: [GENERAL] pgsql over ISDN lines ... |
| Previous Message | Huynh, Long | 2000-01-27 19:16:10 |