有如下数据:
日期 姓名 金额
2008-1-12 sun 100
2008-1-12 张 100
2008-1-13 sun 100
2008-1-19 张 300
2008-2-12 sun 120
2008-2-19 张 300
2008-3-12 sun 130
得到的查询结果:
姓名 2008-01 2008-02 2008-03
sun 200 120 130
张 400 300
0
我的答案(非最佳答案.)
select t1.username "姓名","2009-09","2009-10","2009-11"
from (select username,sum(money) as "2009-09" from SCOTT.MY where datetime between to_date('2009-09-01','yyyy-mm-dd') and to_date('2009-09-30','yyyy-mm-dd') group by username) t1,
(select username,sum(money) as "2009-10" from SCOTT.MY where datetime between to_date('2009-10-01','yyyy-mm-dd') and to_date('2009-10-30','yyyy-mm-dd') group by username) t2,
(select username,sum(money) as "2009-11" from SCOTT.MY where datetime between to_date('2009-11-01','yyyy-mm-dd') and to_date('2009-11-30','yyyy-mm-dd') group by username) t3
where t1.username = t2.username and t2.username = t3.username;
分享到:
相关推荐
The.Wire.S01E13.720p.HDTV.x264-BATV.chs.srt
AWS_中文入门开发教学_-_课程介绍_p.01
Kingston 99P5471-004.A01LF.thp
Narcos.S01E08.720p.WEBRip.x264-TASTETV.繁体&英文
ANSI ISA 95.00.01-2010 Enterprise-Control System Integration - P
BBC.The.World.At.War.1973.EP01-EP26.BluRay.720p.DTS.x264-beAst
Andor.S01E06.1080p.WEB.h264-KOGi[rartv]-[rarbg.to].torrent
Draft P802.11p_D2_01.pdf Draft P802.11p_D2_01.pdf Draft P802.11p_D2_01.pdf Draft P802.11p_D2_01.pdf
文档资源 Gunman.in.Joseon.E11.720p.HDTV.x264-AREA11.txt
docker离线安装包适应于麒麟V10SP1
Person.of.Interest.S01.1080p.BluRay.x264-SHORTBREHD.nfo
Xshell最新版正版Xshell-6.0.01p.zip
paksinian01-MODNAME-P.pak
酷派5910_4.0.048.P1.121210.5910.CPB.part01.rar(要5个文件放到一起解压缩)
AspJpeg缩略图组件1.4.01.4.0 asp图片组件
\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf\P89V51RD2-01_cn.pdf
西门子SINAMICS_G系列变频器固件文件下载链接合集(非常全面2021.01.25)
systemd-pam-239-51.el8.x86_64.rpm
AUO_B104SN01.pdf AUO_B121EW03(V7).pdf AUO_B141EW01 V3.pdf AUO_B141EW02 V3.pdf AUO_B141PW01 V.1.pdf AUO_B154EW01.pdf AUO_B154EW01 v8.pdf AUO_B154EW01 V.8.pdf AUO_B156XW01_V0.pdf AUO_B170PW03 V...