首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请问一条SQL语句!(补充说明)

2012-02-09 
请教一条SQL语句!(补充说明)select DateName(month,EXEC_TIME)as日期, COUNT(*)as总数,substring(mess

请教一条SQL语句!(补充说明)
select DateName(month,EXEC_TIME)as'日期', COUNT(*)as'总数',substring(message,9,7) from GATEWAY_SMS_LOG where DateName(year,EXEC_TIME)=2011 and service_type_id='sms' and (MESSAGE like '%8%' or MESSAGE like '%9%') group by DateName(month,EXEC_TIME),substring(message,9,7)

显示的结果是:

日期 总数 (无列名)
04 1 8814145
04 1 8814146
04 1 8818956
03 1 8911318
03 2 8911319
04 2 9075268


我想显示汇总该怎么显示呀?

03 3
04 4


03 3
04 5
这个我也会显示;
问题是4月份有两条一样的记录
04 2 9075268
我只算是一条。所以结果应该是
03 3
04 4 不是 04 5 

无列名的号码都是 字符串里结出来的。






[解决办法]
照你的说法,03应该是2啊
03 2 8911319这个不是两条一样吗
[解决办法]

SQL code
select 日期,count(*) from(select DateName(month,EXEC_TIME)as'日期', COUNT(*)as'总数',substring(message,9,7) as col from GATEWAY_SMS_LOG where DateName(year,EXEC_TIME)=2011 and service_type_id='sms' and (MESSAGE like '%8%' or MESSAGE like '%9%') group by DateName(month,EXEC_TIME),substring(message,9,7))t group by 日期/*03 204 4*/ 

热点排行