Hi,
Can someone help me on this problem i have...
I'm using hibernate...and have a table named case_score_t with these columns: id, case_id, user_id, score, created_date
I am interested in picking the rows with the greatest created_date, for a certain user_id.
I have this SQL currently "SELECT cs FROM CaseScore cs WHERE cs.user.id = ? GROUP BY cs.c.id ORDER BY cs.created DESC" but this will not provide me the correct result!!!
This SQL with give me the correct result: SELECT *, max(created) FROM case_score_t cs WHERE cs.user_id = 1449 GROUP BY cs.case_id;
The problem is that i have is that i get an extra column, the max(created) column back.
Is there anyway to do the same query(maybe with criteria or subselect's...), without getting the extra max(created) column, but still getting the rows with the greatest created date, for a certain user... ?
Because i want to be able to do a SELECT cs ... rather than picking the max(created) as a separate column.
Any help will be appreciated...
Best Regards Cemils
|