SELECT DISTINCT ( CASE
WHEN RIGHT(A.KSTerm, 1) = 1 THEN A.KSTerm + '上学期'
WHEN RIGHT(A.KSTerm, 1) = 2 THEN A.KSTerm + '下学期'
ELSE ''
END ) AS XQ
FROM [dbo].[Test] A
WHERE LEFT(A.KSTerm, 4) > ( Year(Getdate()) - 3 )
ORDER BY XQ