易截截图软件、单文件、免安装、纯绿色、仅160KB

oracle 自定义分组 - Oracle / 基础和管理

select sum(a.t)from ta a group by ta.a,这条语句将表ta中的数据按照a字段分组汇总t字段。
结果比如:

3 30
4 50
我想得到这个结果:
1 0
2 0
3 30
4 50
5 0
这个结果,请问sql语句怎么写?多谢
nobody knows?

可以把你的1、2、3、4、5放到另外一张表中,然后通过外连接进行查询
再decode(sum(a.t),null,0,sum(a.t))

引用
可以把你的1、2、3、4、5放到另外一张表中,然后通过外连接进行查询
再decode(sum(a.t),null,0,sum(a.t))

up

SQL code:
select ROWNUM,0 from 有数据的表(表记录>你想要的序列N,你的例子里是5) where ROWNUM <5
例如 SELECT ROWNUM,0 AS AGE from EMP where ROWNUM <5
ROWNUM AGE
1 0
2 0
3 0
4 0
5 0
SELECT * from A;
ID AGE
1 30
3 40
select id,max(AGE) from
(SELECT ROWNUM ID,0 AS AGE from EMP where ROWNUM <=5
union
SELECT * from A)
group by id







select t1.rn, nvl(sum(t2.t),0) from
(select rownum rn from dual connect by rownum <= 5) t1,
ta t2
where t1.rn = t2.a(+)
group by t1.rn;

select t.l, nvl(sum(t2.t),0) from 
(
select level l from dual connect by level <=5) t  
left join ta t2 on (t.l = t2.a)
group by t.l

case when sum(columnname) = 0 then 0
else then sum(c


相关问答:

oracle 10g web登陆EM的问题? - Oracle / 基础和管理

安装了Oracle 10g,默认安装了orcl数据库,这个数据库能不能删除啊,还有我如果新建了其他数据库,怎么知道在web中登陆不同数据库的地址啊?

1
可以删除
2
在WEB地址栏中输入地址的时候指定新创建的数据库的IP ......

Oracle 数据导出问题 - Oracle / 高级技术

exp user/password@dbname file=c:\table.dmp tables=jbitaku,jbitakum grants=y
然後按回車鍵 說明:  user/password@dbname  分別表示用戶名,密碼和服務名 f ......

oracle数据库的名字问题 - Oracle / 基础和管理

我在创建数据库的时候用的名字为oracle10,但是创建好后,在默认的目录下显示的名称却是oracle10g,这是为什么?
你看的 10g是安装目录吧 

SQL> select name from v$database;
NAME
---------
ORCL ......

多表关联查询的 sql写法 - Oracle / 基础和管理

大家好,我最近维护一个项目,100多个表
只能用jdbc直连
遇到了多个表 关联 查询的情况 请大家指教
比如
student(studentid,classid)
class(classid,classname)
class_teacher(classid,teacherid)这个是中间表 ......

sql - Oracle / 非技术区

score表
scoreid course studentid score
1 数学 2 99
2 数学 3 60
3 数学 4 80
4 语文 5 79
5 语文 6 58
6 语文 1 66
7 英语 6 76
8 英语 4 87
9 英语 3 100
10英语 2 69
怎样得到没门课中分数最高的那 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号