davej Posted March 31, 2012 Share Posted March 31, 2012 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. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 2, 2012 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 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
Archived
This topic is now archived and is closed to further replies.