• Post Reply Bookmark Topic Watch Topic
  • New Topic

please help on a sql query

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got stuck one sql query. Say, we have a table:


Now I want to pull out each category's lattest one. Therefore, the result should be


Any hints / solution ?

Thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36027
431
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edward,
You can use a nested query to get the primary key for the maximum of each category. "group by" lets you group by category name. Then you can get the values for that primary key.

Give it a shot and then we can tweak the SQL here.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!