select c,'' as b,sum(a) as a from tb where c is not null group by c
union all
select * from tb where c is null是不是这个意思?
union all
select * from tb where c is null是不是这个意思?
解决方案 »
- 怎么对ntext字段实行replace函数?
- 我把administrator开机密码改了,sql服务器打不开了,怎么办
- 一个简单的update怎么就是出错呢?请帮我看看谢谢
- 游标三层循环的存储过程,求优化
- 怎样在保持现有数据不丢失的情况下,减小 *.LDF 文件的大小???在线等!!!急!!
- 如何比较二个表中的数据???急
- 有关用友U8系统的数据库?
- 哪种数据库文件可以 把 任意文件 封装在 自己里面?
- SQL2000与SQL7.0备份一样吗?
- sqlserver中的自增字段(就象ORACLE中的序列号)是什么?怎么用?
- SQL存储过程求max,min,avg,sum
- sql2008 能否设置定时作业(每天07:00)定时重启数据库?
create table test (A int, B varchar(10),C varchar(10))
insert test
select 10,'甲','A公司' union all
select 10,'已','A公司' union all
select 20,'丙','' union all
select 15,'丁','B公司' union all
select 25,'大花','' union all
select 10,'小花','A公司'select SUM(A),MIN(B),C
from test
where ISNULL(C,'')<>''
group by C
union all
select A,B,C
from test
where ISNULL(C,'')=''/*
30 甲 A公司
15 丁 B公司
20 丙
25 大花
*/