davej Posted March 31, 2012 Report Share Posted March 31, 2012 (edited) I saw an interesting question a few days ago. They had a table with a compound primary key and they wanted to select the MAX() entries for each category. So the table was like... dept CHAR(6),project_no INT,description CHAR(15),manager CHAR(15)CONSTRAINT PRIMARY KEY(dept, project_no) They wanted to find the highest project_no in each department. --Edited: Corrected the example. Edited April 2, 2012 by davej Link to comment Share on other sites More sharing options...
justsomeguy Posted April 2, 2012 Report Share Posted April 2, 2012 This is what the GROUP BY statement is for. http://www.w3schools.com/sql/sql_groupby.asp Link to comment Share on other sites More sharing options...
davej Posted April 3, 2012 Author Report Share Posted April 3, 2012 I will have to try again. I could not get it to work, but then I am getting rusty on SQL. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now