Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure Question

Status
Not open for further replies.

darude

Programmer
Jun 23, 2003
138
0
0
US
Hello,
I have a stored procedure where I need criteria on the YOG that says if the current month is > 9 then YOG = Year(date() else YOG = Year(date() - 1).

I have this case statement but don't know where it should go in the SELECT:
CASE When month(getdate()) > 9 then Year(getdate()) else Year(getdate()) - 1.

SELECT StudMR.StudMRGradYear AS YOG,
StudMR.StudMRSchoolID
FROM StudMR
INNER JOIN Schools ON StudMR.StudMRSchoolID = Schools.SchoolID
WHERE (((Schools.SchoolType)='exam' Or
(Schools.SchoolType)='district' Or
(Schools.SchoolType)='alternative'))
GROUP BY StudMR.StudMRGradYear,
StudMR.StudMRSchoolID
ORDER BY StudMR.StudMRGradYear DESC;

Thank you in advance.
 
Looks like YOG is an alias for StudMR.StudMRGradYear.
So replace StudMR.StudMRGradYear wit your new case statment. Make sure you put END at the end of case statement.Same thing has to be added to your group by also.
HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top