msisdn createtime closetime
138 2011-5-17 15:30:00:000 2011-5-17 15:30:00:530
138 2011-5-17 15:40:00:000 2011-5-17 15:40:00:530
怎么用sql语句查询出138这个号码一共用了多少时间?
===============================================
select sum(datediff(millisecond,createtime, closetime))as 总豪秒数 from 表名 where msisdn=138
select sum(datediff(minute,createtime, closetime))as 总秒数 from 表名 where msisdn=138
select sum(datediff(minute,createtime, closetime))as 总分钟 from 表名 where msisdn=138
select sum(datediff(Hour,createtime, closetime))as 总小时 from 表名 where msisdn=138
select sum(datediff(Day,createtime, closetime))as 总天数 from 表名 where msisdn=138
select sum(datediff(week,createtime, closetime))as 总天数 from 表名 where msisdn=138
select sum(datediff(Month,createtime, closetime))as 总天数 from 表名 where msisdn=138
select sum(datediff(quarter,createtime, closetime))as 总季数 from 表名 where msisdn=138
select sum(datediff(year,createtime, closetime))as 总年数 from 表名 where msisdn=138