查询结果如图:
一个表存的是地区、一个表存的是日期(yyyy-mm-dd)和日销量
oracle数据库中怎么查询交叉表?
答案:3 悬赏:40
解决时间 2021-03-14 01:37
- 提问者网友:单纯说谎家
- 2021-03-13 10:20
最佳答案
- 二级知识专家网友:青春如此荒謬
- 2021-03-13 11:26
select 地区名称 地区,month(日期)+'月'+day(日期)+'日' 日期,
sum(case when year(日期)=2010 then 日销量 end) 2010年,
sum(case when year(日期)=2011 then 日销量 end) 2011年,
sum(case when year(日期)=2012 then 日销量 end) 2012年,
sum(case when year(日期)=2013 then 日销量 end) 2013年
from 销量表,地区表
where 销量表.地区id=地区表.id
group by 地区,month(日期)+'月'+day(日期)+'日'
sum(case when year(日期)=2010 then 日销量 end) 2010年,
sum(case when year(日期)=2011 then 日销量 end) 2011年,
sum(case when year(日期)=2012 then 日销量 end) 2012年,
sum(case when year(日期)=2013 then 日销量 end) 2013年
from 销量表,地区表
where 销量表.地区id=地区表.id
group by 地区,month(日期)+'月'+day(日期)+'日'
全部回答
- 1楼网友:如果这是命
- 2021-03-13 12:52
要查什么东西,说详细点!
- 2楼网友:为你轻狂半世殇
- 2021-03-13 12:45
查询表中数据信息:select * from abc
查询表在库中信息:select * from all_tables where table_name = 'abc' (系统表all_table使用时后面条件参数一概用大写。。)
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯