[求助]请问在存储过程中如何使用判断语句取值
比如下面这个例子:G>=85 GP=4
85>G>=75 GP=3
75>G>=60 GP=2
60>G GP=1
G是SC表中的"分数项",SNO为SC的"学号"每个学生有好几个G
如何根据学号确定学生的GP的和?
USE pubs GO SELECT Category = CASE type WHEN 'popular_comp' THEN 'Popular Computing'
WHEN 'mod_cook' THEN 'Modern Cooking'
WHEN 'business' THEN 'Business'
WHEN 'psychology' THEN 'Psychology'
WHEN 'trad_cook' THEN 'Traditional Cooking'
ELSE 'Not yet categorized'
END,
CAST(title AS varchar(25)) AS 'Shortened Title',
price AS Price
FROM titles
WHERE price IS NOT NULL
ORDER BY type, price
COMPUTE AVG(price) BY type
GO
看看能不能看明白了啊?