MySQL Forums
Forum List  »  InnoDB

Group by
Posted by: Aram Karapetyan
Date: January 06, 2006 06:34AM

Hello all.
Merry christmas and happy new year to all.

At first I want to sorry for my english and mey be I dublicate question.

The question is that in case of groupping (group by some_column) lines mysqld return first lines from groups how can I get lines buy some critery.

table
===========
| id | col1 | col2 |
| 1 | a1 | b1 |
| 2 | a1 | b2 |
| 3 | a1 | b3 |
| 4 | a2 | c1 |
| 4 | a2 | c2 |
| 4 | a2 | c3 |
=========

SELECT * from table1
where col1 = 'some_value'
group by col2

This query will return lines with id 1 and 2.
I need to get last lines for each group.

Thank you.
Again sorry for english.

Options: ReplyQuote


Subject
Views
Written By
Posted
Group by
3279
January 06, 2006 06:34AM
1783
January 06, 2006 01:55PM
1724
January 07, 2006 01:06AM
1744
January 07, 2006 02:49AM
1862
January 08, 2006 07:42AM
1856
January 08, 2006 07:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.