Top "Greatest-n-per-group" questions

Query the row with the greatest/least value per group.

Get the latest date from grouped MySQL data

I have the following data in my database: |NO | model | date | +---+-------+----------+ |1 | bee |2011-12-01| |2 | bee |2011-12-05| |3 | …

mysql sql date greatest-n-per-group
How to select id with max date group by category in PostgreSQL?

For an example, I would like to select id with max date group by category, the result is: 7, 2, 6 id category …

sql postgresql greatest-n-per-group
Mysql select distinct

I am trying to select of the duplicate rows in mysql table it's working fine for me but the problem …

mysql select greatest-n-per-group
FORCE INDEX mySQL ...where do I put it?

I have the following mySQL query that works perfectly fine. Except that I need to add a "FORCE INDEX" and …

mysql indexing greatest-n-per-group
How to get the latest record in each group using GROUP BY?

Let's say I have a table called messages with the columns: id | from_id | to_id | subject | message | timestamp I …

mysql sql greatest-n-per-group
How to select the most recent set of dated records from a mysql table

I am storing the response to various rpc calls in a mysql table with the following fields: Table: rpc_responses …

mysql sql date greatest-n-per-group
T-SQL: Selecting Column Based on MAX(Other Column)

I'm hoping there's a simple way to do this without using a sub-query: Scenario: You have "TableA" with columns "Key", "…

sql sql-server tsql greatest-n-per-group
Get top results for each group (in Oracle)

How would I be able to get N results for several groups in an oracle query. For example, given the …

sql oracle greatest-n-per-group
SQL: Find the max record per group

Possible Duplicate: Retrieving the last record in each group I have one table, which has three fields and data. Name , …

sql mysql greatest-n-per-group
Select multiple (non-aggregate function) columns with GROUP BY

I am trying to select the max value from one column, while grouping by another non-unique id column which has …

sql ms-access greatest-n-per-group