select sum(case when g.golffield_ball = 0 then 1 else 0 end) 高尔夫球,sum(case when g.golffield_ball = 1 then 1 else 0 end) 羽毛球,sum(case when g.golffield_ball = 3 then 1 else 0 end) 乒乓球,sum(case when g.golffield_ball = 5 then 1 else 0 end) 保龄球,sum(case when g.golffield_ball = 2 then 1 else 0 end) 台球,sum(case when g.golffield_ball = 4 then 1 else 0 end) 网球,sum(case when g.golffield_ball = 6 then 1 else 0 end) 篮球,sum(case when g.golffield_ball = 7 then 1 else 0 end) 足球from golffield g where g.GOLFFIELD_CITY like '%唐山%' and g.golffield_delflag = 0我想把唐山两个字放在最前执行结果里面!可以吗?求帮助!
sql 语句添加列
答案:2 悬赏:0 手机版
解决时间 2021-03-21 00:09
- 提问者网友:疯子也有疯子的情调
- 2021-03-20 13:48
最佳答案
- 五星知识达人网友:痴妹与他
- 2021-03-20 14:55
select g.GOLFFIELD_CITY,
sum(case when g.golffield_ball = 0 then 1 else 0 end) 高尔夫球,
sum(case when g.golffield_ball = 1 then 1 else 0 end) 羽毛球,
sum(case when g.golffield_ball = 3 then 1 else 0 end) 乒乓球,
sum(case when g.golffield_ball = 5 then 1 else 0 end) 保龄球,
sum(case when g.golffield_ball = 2 then 1 else 0 end) 台球,
sum(case when g.golffield_ball = 4 then 1 else 0 end) 网球,
sum(case when g.golffield_ball = 6 then 1 else 0 end) 篮球,
sum(case when g.golffield_ball = 7 then 1 else 0 end) 足球
from golffield g
where g.GOLFFIELD_CITY like '%唐山%' and g.golffield_delflag = 0
group by g.GOLFFIELD_CITY
--或者
select '唐山' GolfCity,
sum(case when g.golffield_ball = 0 then 1 else 0 end) 高尔夫球,
sum(case when g.golffield_ball = 1 then 1 else 0 end) 羽毛球,
sum(case when g.golffield_ball = 3 then 1 else 0 end) 乒乓球,
sum(case when g.golffield_ball = 5 then 1 else 0 end) 保龄球,
sum(case when g.golffield_ball = 2 then 1 else 0 end) 台球,
sum(case when g.golffield_ball = 4 then 1 else 0 end) 网球,
sum(case when g.golffield_ball = 6 then 1 else 0 end) 篮球,
sum(case when g.golffield_ball = 7 then 1 else 0 end) 足球
from golffield g
where g.GOLFFIELD_CITY like '%唐山%' and g.golffield_delflag = 0
sum(case when g.golffield_ball = 0 then 1 else 0 end) 高尔夫球,
sum(case when g.golffield_ball = 1 then 1 else 0 end) 羽毛球,
sum(case when g.golffield_ball = 3 then 1 else 0 end) 乒乓球,
sum(case when g.golffield_ball = 5 then 1 else 0 end) 保龄球,
sum(case when g.golffield_ball = 2 then 1 else 0 end) 台球,
sum(case when g.golffield_ball = 4 then 1 else 0 end) 网球,
sum(case when g.golffield_ball = 6 then 1 else 0 end) 篮球,
sum(case when g.golffield_ball = 7 then 1 else 0 end) 足球
from golffield g
where g.GOLFFIELD_CITY like '%唐山%' and g.golffield_delflag = 0
group by g.GOLFFIELD_CITY
--或者
select '唐山' GolfCity,
sum(case when g.golffield_ball = 0 then 1 else 0 end) 高尔夫球,
sum(case when g.golffield_ball = 1 then 1 else 0 end) 羽毛球,
sum(case when g.golffield_ball = 3 then 1 else 0 end) 乒乓球,
sum(case when g.golffield_ball = 5 then 1 else 0 end) 保龄球,
sum(case when g.golffield_ball = 2 then 1 else 0 end) 台球,
sum(case when g.golffield_ball = 4 then 1 else 0 end) 网球,
sum(case when g.golffield_ball = 6 then 1 else 0 end) 篮球,
sum(case when g.golffield_ball = 7 then 1 else 0 end) 足球
from golffield g
where g.GOLFFIELD_CITY like '%唐山%' and g.golffield_delflag = 0
全部回答
- 1楼网友:白昼之月
- 2021-03-20 16:33
alter table 表名 add 列名 数据类型
如:alter table student add nickname char(20)
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯