I need to do something in SQL and I’m currently confused!
So I have something like this:
idEvent idService dateCreated
------- --------- -----------
1 1 2012-01-01
2 1 2012-02-02
3 2 2012-01-01
4 2 2012-02-02
The idEvent is auto-incrementing.
What I need to get is the biggest row (ordered by dateCreated DESC) for each idService.
So I’d need to get this as a result :
idEvent
-------
2
4
You can use a common table expression to apply a “row number” to each idService / dateCreated combination. You didn’t specify your table name, so you’ll have to fix that.