|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
I have a table of transactions for users. I want to return the last transaction for each user. What would the sql statement be? What if i wanted to return the last 3 transactions for each user? Any would be great. Thanks. Andrew. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 11 Feb, 10:55, bart3r <andrewbar...@gmail.com> wrote:
> Hello, > > I have a table of transactions for users. > > I want to return the last transaction for each user. What would the > sql statement be? > What if i wanted to return the last 3 transactions for each user? > > Any would be great. > Thanks. > Andrew. Hi there, welcome to comp.databases.mysql The last transaction by user would be: http://dev.mysql.com/doc/refman/5.0/...group-row.html (it tends to be known as the Strawberry Query round here). You want the third example, the one with the LEFT JOIN. As to the other question, a Google search for: mysql top n group finds this on the first results page: http://thenoyes.com/littlenoise/?p=36 |
|
![]() |
| Outils de la discussion | |
|
|