标题:SQL case 语句怎么用
取消只看楼主
_eagle_ice
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-3-15
 问题点数:0 回复次数:1 
SQL case 语句怎么用
最好能给个例子  谢谢
搜索更多相关主题的帖子: SQL case 语句 例子 
2008-04-25 13:40
_eagle_ice
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-3-15
得分:0 
case
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
2008-05-15 21:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-211016-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024383 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved