A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
please help on a sql query
Joined: Dec 23, 2003
Jun 26, 2007 07:54:00
I got stuck one sql query. Say, we have a table:
pk1 category1 1970/1/1 pk2 category1 1970/1/2 pk3 category2 1970/2/1 pk4 category2 1970/2/2
Now I want to pull out each category's lattest one. Therefore, the result should be
pk2 category1 1970/1/2 pk4 category2 1970/2/2
Any hints / solution ?
Joined: May 26, 2003
Jun 26, 2007 17:48:00
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.
How To Ask Questions The Smart Way
Blogging on Certs:
SCEA Part 1
Part 2 & 3
Core Spring 3
TOGAF part 1
rocket mass heater
subject: please help on a sql query
Dollar Symbol at Vertical Bar in StackedBarChar in JFreeChart
logic:iterate hashmap with key of hashmap
how to load select options using jstl with selected and disabled
Tomcat Configuration with more than 2,000 apps
selectManycheckboxes with subheading
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013