I'm trying to use a query for both a search function and another query function with parameters taken from controls. At the end of the query, I'm trying to use a CASE function to determine the where clause, but I keep getting a syntax error related to the CASE function, but I can't see the problem. Can anyone see it or am I way off here?Thanks!ERROR: Incorrect syntax near the keyword 'CASE'.select a.assignment_id, s.student_id, s.student, e.elective, a.isLottery, a.status, b.start_dt, b.end_dt, s.coord_notes, a.assign_dtfrom(select assignment_id, block_id, student_id, status, isLottery, assign_dtfrom assignments) as ainner join(select block_id, elective_id, start_dt, end_dtfrom block_schedule) as bon a.block_id=b.block_idinner join(select elective_id, elective_name as electivefrom electives) as eon b.elective_id=e.elective_idinner join(select student_id as student_id, lastname + ', ' + firstname + ' ' + middlename as student, isNULL(coord_notes,' ') as coord_notes, activefrom student where active=@active) as son a.student_id=s.student_idCASE s.student WHEN '' THEN where ( status like '%' + @status + '%' and year(start_dt) =@year and active=@active)ELSE where (s.student like '%' + @search + '%') ENDorder by s.student, e.elective,b.start_dt