IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [SQL]SELECT 语句中的 CASE 子句用法
猫猫草
post 2012-05-08 10:49:14, Tue
Post #1


猫猫猫
***

Group: Power Cat
Posts: 626
Joined: 2006-12-8
Member No.: 2



代码
case
    when <关系条件表达式> then <SQL语句或者返回值>
    when <关系条件表达式> then <SQL语句或者返回值>
    ...
    when <关系条件表达式> then <SQL语句或者返回值>
    else <SQL语句或者返回值>
end


举例

代码
select count(case when a.zt='07' then a.bs end),
count(case when a.zt='11' then a.bs end)
from dj_zt a
where a.qylx_dm = '03
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 2024-11-1 10:29