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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Semester equals Max date

Author  Topic 

giszzmo
Starting Member

29 Posts

Posted - 2015-01-26 : 17:36:35
Hello, I have a query that needs to display all grades within the current semester. Grades are usually updated every day, but occasionally they are not so I have to use the MAX function to return the latest grades and to determine what the current semester is. I am not sure how to query all grades in "Spring," which should match that of the MAX date. It can't be hard coded either. The data I'm working with looks like:
Semester Date
Spring 2015-01-15
Spring 2015-01-13
Spring 2015-01-09
Fall 2014-12-21
Fall 2014-21-11
Fall 2014-01-07

I was thinking it should be in the WHERE clause:
WHERE Semester like (select MAX(convert(date,GradeDate))'Grade Date')


Basically, whatever the semester is for the MAX date, that's the semester that I need all the grades from and all the dates that they were uploaded (not just MAX). If anyone could point me in the right direction. Thanks!

waterduck
Aged Yak Warrior

982 Posts

Posted - 2015-01-26 : 20:45:49
can you show how is yours expected result will looks like?
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-01-27 : 09:09:17
Sounds like a homework question. You need to work on it a bit more before posting here.
Go to Top of Page

giszzmo
Starting Member

29 Posts

Posted - 2015-01-27 : 09:27:55
Lol! Sounds like not!
Go to Top of Page

viggneshwar
Yak Posting Veteran

86 Posts

Posted - 2015-01-28 : 03:12:59
Use the max(semesterdate) in group by semestername. That will give you the max date of all the semesters. Using that result you can perform your logics

Regards
Viggneshwar A
Go to Top of Page
   

- Advertisement -