Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
PJones1
Starting Member
1 Post |
Posted - 2010-03-18 : 16:06:05
|
I am very very new to SQL. I attempted to write a select query to grab the graduation year from a table, but the tabel has multiple records. How should I write it to select the last year.Example: Select Schedule.StudentID, Schedule.FullName From Schedule INNER JOIN Enrollments ON Schedule.StudentID = Enrollments.StudentIDWHERE (GraduationYear = 2010) |
|
|
RobertKaucher
Posting Yak Master
169 Posts |
Posted - 2010-03-18 : 18:21:39
|
| This sounds like home work... If the column you are trying to match is a datetime, Google the YEAR() function.If the column you are trying to match is some other data type put try puting the year in single quotes.GraduationYear = '2010' |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-19 : 11:41:19
|
| provided GraduationYear is integer type you need to apply MAX() over it to get maximum year value------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|