select errortype as 类型,count(*) as 总数 from errormessage a where a.errortime > '2010-04-07' group by a.errortype order by a.errortype 得到的结果是:
类型 总数
1 22
2 13
3 63
6 46
8 12
select errortype as 类型,count(*) as 已查看数 from errormessage a where a.errortime > '2010-04-07' and a.lookflag = '1' group by a.errortype order by a.errortype
得到的结果是:
类型 已查看数
1 18
2 5
8 8
现在想写一个SQL语句得到以下的结果:
类型 总数 已查看数
1 22 18
2 13 5
3 63 0
6 46 0
8 12 8
下面这个语句不行,请教大家。我SQL基础不行,多谢大家了。
select a.errortype as 类型,count(*) as 总数,b.bb as 已查看数 from errormessage a,(select errortype as 型,
count(*) as bb from errormessage where errortime > '2010-04-07' and lookflag = '1' group by errortype ) b
where a.errortime > '2010-04-07' group by a.errortype,b.bb order by a.errortype
类型 总数
1 22
2 13
3 63
6 46
8 12
select errortype as 类型,count(*) as 已查看数 from errormessage a where a.errortime > '2010-04-07' and a.lookflag = '1' group by a.errortype order by a.errortype
得到的结果是:
类型 已查看数
1 18
2 5
8 8
现在想写一个SQL语句得到以下的结果:
类型 总数 已查看数
1 22 18
2 13 5
3 63 0
6 46 0
8 12 8
下面这个语句不行,请教大家。我SQL基础不行,多谢大家了。
select a.errortype as 类型,count(*) as 总数,b.bb as 已查看数 from errormessage a,(select errortype as 型,
count(*) as bb from errormessage where errortime > '2010-04-07' and lookflag = '1' group by errortype ) b
where a.errortime > '2010-04-07' group by a.errortype,b.bb order by a.errortype
解决方案 »
- 修改数据文件(我不懂,但是不装懂)
- 学 SQL SERVER 需要现学好 access 吗?
- sql server数据导入导出数据流任务: 出现OLE DB错误。错误代码: 0x80004005
- 求各位高手帮忙 ,????急急急 在线等待
- 请问SQLSERVER存储过程中怎样判断一个游标是否存在?
- ****************关于两表数据同步的触发器怎么实现?********************
- 继续刚才的问题~笨猫之后续(四)
- Report Builder3.0如何设置每页都有标题
- 存储过程问题!
- sql server数据更新问题
- 如何表示是一串字符?
- 郁闷 ,今天才看到union 与union all 的区别!
from errormessage a
where a.errortime > '2010-04-07'
group by a.errortype
order by a.errortype
from (你第一個語句) A
left join
(你第二個語句) B
on A.类型=B.类型
select errortype as 类型,count(*) as 总数,sum(case lookflag when '1' then 1 else 0 end ) as 已查看数 from errormessage a where a.errortime > '2010-04-07' group by a.errortype order by a.errortype
from (你第一個語句) A
left join
(你第二個語句) B
on A.类型=B.类型
现在就是errortype还有别的值,总数为0目前没显示出来。想得到下面的结果:
类型 总数 已查看数
0 0 0
1 22 18
2 13 5
3 63 0
4 0 0
5 0 0
6 46 0
7 0 0
8 12 8
应该怎样修改下SQL语句,解决马上结贴。多谢