Say I have a Person
table and a Courses
table. In the Person
table I have the column PersonName
. In the Courses
table, let's say I have CourseTitle
,PersonName
and CourseDifficulty
. CourseDifficulty
is 1-4 (4 being the hardest). How do I return a list of people from Person
and for each person have a column that shows the most difficult class they're taking by CourseTitle
.
As far as I know, I'd get the CourseTitle of the most difficult class Brett is taking by doing the following:
SELECT CourseTitle
FROM Courses
WHERE PersonName = 'Brett'
AND CourseDifficulty = (SELECT MAX(CourseDifficulty)
FROM Courses
WHERE PersonName='Brett')
But how do I run that for each person in the Person table? I want the results to be something like
Brett-SQL For Dummies 4
Tim-Quantum Mechanics
Jane-Thermodynamics 2
Sorry for the noobness. Thanks in advance for the help!