New solution (PostgreSQL 8.4)
SELECT
*
FROM (
SELECT
ROW_NUMBER() OVER (PARTITION BY section_id ORDER BY name) AS r,
t.*
FROM
xxx t) x
WHERE
x.r <= 2;
More Related Contents:
- How to concatenate strings of a string field in a PostgreSQL ‘group by’ query?
- Does PostgreSQL support “accent insensitive” collations?
- PostgreSQL DISTINCT ON with different ORDER BY
- PostgreSQL: running count of rows for a query ‘by minute’
- Split comma separated column data into additional columns
- IN vs ANY operator in PostgreSQL
- How to include “zero” / “0” results in COUNT aggregate?
- SQL SELECT speed int vs varchar
- delete “column does not exist”
- How to create a temporary function in PostgreSQL?
- Postgres Case Sensitivity
- Polymorphism in SQL database tables?
- Record returned from function has columns concatenated
- INSERT rows into multiple tables in a single query, selecting from an involved table
- How to round an average to 2 decimal places in PostgreSQL?
- Explain JOIN vs. LEFT JOIN and WHERE condition performance suggestion in more detail
- How to find a table having a specific column in postgresql
- postgresql: INSERT INTO … (SELECT * …)
- PostgreSQL JOIN with array type with array elements order, how to implement?
- Trim trailing spaces with PostgreSQL
- Return multiple columns and rows from a function PostgreSQL instead of record
- Postgres error updating column data
- Check whether string is a date Postgresql
- SQL LIKE condition to check for integer?
- PostgreSQL 9.3: Dynamic pivot table
- How to detect query which holds the lock in Postgres?
- PostgreSQL how to create a copy of a database or schema?
- PostgreSQL: fill NULL values in timeserie query with previous value
- Postgres: convert single row to multiple rows (unpivot)
- Get most common value for each value of another column in SQL