Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Facebook
Downloads
Home
>
mailing lists
query question - Mailing list pgsql-novice
From
pg noob
Subject
query question
Date
September 21, 2011
02:14:57
Msg-id
CAPNY-2U9aQHp54gzw6nXN13kwjv2P1e76B=RnMyF2kvT9Qj7Vw@mail.gmail.com
Whole thread
Raw
Responses
Re: query question
Re: query question
List
pgsql-novice
Tree view
Hi all,
Is there an efficient way to select the set of rows which have the max values across multiple columns?
For example given this list of data,
id_ | col1 | col2 | col3
-------+-------------+------------------+-----------------
19657 | 10 | 1316114172563817 | 4
19656 | 10 | 1316114172563817 | 3
24 | 12 | 1315847688545745 | 0
19644 | 13 | 1316114172563817 | 0
26 | 14 | 1315847688545745 | 0
19646 | 15 | 1316114172563817 | 0
19582 | 15 | 1316112258713414 | 0
18269 | 15 | 1316023202508054 | 0
199 | 15 | 1315936801616950 | 0
37 | 15 | 1315847702117357 | 0
19648 | 16 | 1316114172563817 | 0
19583 | 16 | 1316112258713414 | 0
18272 | 16 | 1316023202508054 | 0
202 | 16 | 1315936801616950 | 0
38 | 16 | 1315847702117357 | 0
19652 | 17 | 1316114172563817 | 0
19585 | 17 | 1316112258713414 | 0
18276 | 17 | 1316023202508054 | 0
206 | 17 | 1315936801616950 | 0
39 | 17 | 1315847702117357 | 0
I would like to select the set of rows grouped by col1 which has first the highest value for col2 and second the highest value for col3.
The result set should include:
19657 | 10 | 1316114172563817 | 4
24 | 12 | 1315847688545745 | 0
19644 | 13 | 1316114172563817 | 0
26 | 14 | 1315847688545745 | 0
19646 | 15 | 1316114172563817 | 0
19648 | 16 | 1316114172563817 | 0
19652 | 17 | 1316114172563817 | 0
Thank you.
pgsql-novice
by date:
Previous
From:
Eric Hulburd
Date:
15 September 2011, 14:28:34
Subject:
can't connect to server
Next
From:
Sachin Srivastava
Date:
21 September 2011, 03:16:01
Subject:
Re: query question
Есть вопросы? Напишите нам!
Соглашаюсь с условиями обработки персональных данных
I confirm that I have read and accepted PostgresPro’s
Privacy Policy
.
I agree to get Postgres Pro discount offers and other marketing communications.
✖
×
×
Everywhere
Documentation
Mailing list
List:
all lists
pgsql-general
pgsql-hackers
buildfarm-members
pgadmin-hackers
pgadmin-support
pgsql-admin
pgsql-advocacy
pgsql-announce
pgsql-benchmarks
pgsql-bugs
pgsql-chat
pgsql-cluster-hackers
pgsql-committers
pgsql-cygwin
pgsql-docs
pgsql-hackers-pitr
pgsql-hackers-win32
pgsql-interfaces
pgsql-jdbc
pgsql-jobs
pgsql-novice
pgsql-odbc
pgsql-patches
pgsql-performance
pgsql-php
pgsql-pkg-debian
pgsql-pkg-yum
pgsql-ports
pgsql-rrreviewers
pgsql-ru-general
pgsql-sql
pgsql-students
pgsql-testers
pgsql-translators
pgsql-www
psycopg
Period
anytime
within last day
within last week
within last month
within last 6 months
within last year
Sort by
date
reverse date
rank
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
By continuing to browse this website, you agree to the use of cookies. Go to
Privacy Policy
.
I accept cookies