笔试的时候遇到一题,
具体情况忘记了,反正有个字段是 day 像“2008-05-06”
有查询某一天的通话数量 我大概这样写的
select count(通话数量) from 表 where day='2005-05-05'有查询某个月的通话数量 大概这样写了
select count(通话数量) from 表 where day (between '2005-05-01' and '2005-05-31')
(不知道有没有什么好方法!!)有查询某个月中除了某天 外的所有通话记录,不知道怎么写,希望高手指点,谢谢!
具体情况忘记了,反正有个字段是 day 像“2008-05-06”
有查询某一天的通话数量 我大概这样写的
select count(通话数量) from 表 where day='2005-05-05'有查询某个月的通话数量 大概这样写了
select count(通话数量) from 表 where day (between '2005-05-01' and '2005-05-31')
(不知道有没有什么好方法!!)有查询某个月中除了某天 外的所有通话记录,不知道怎么写,希望高手指点,谢谢!
select count(*) from 表 where datediff(dd,day,'2005-05-05')=0--月
select count(*) from 表 where datediff(mm,day,'2005-05-05')=0
and datepart(dd,day) not in(5,6,10)当月,但不包含 5,6,10号
具体情况忘记了,反正有个字段是 day 像“2008-05-06” 有查询某一天的通话数量 我大概这样写的
select count(通话数量) from 表 where day='2005-05-05' select count(*) from 表 where convert(varchar(10),[day],120) = '2005-05-05'
有查询某个月的通话数量 大概这样写了
select count(通话数量) from 表 where day (between '2005-05-01' and '2005-05-31') select count(*) from 表 where convert(varchar(7),[day],120) = '2005-05'(不知道有没有什么好方法!!) 有查询某个月中除了某天 外的所有通话记录,不知道怎么写,希望高手指点,谢谢!
--一天
select count(*) from 表 where convert(varchar(7),[day],120) = '2005-05' and convert(varchar(10),[day],120) <> '2005-05-05'
--多天
select count(*) from 表 where convert(varchar(7),[day],120) = '2005-05' and convert(varchar(10),[day],120) not in('2005-05-05','2005-05-06','2005-05-07')