如何筛选出不需要的数据?

sy4722 2008-04-03 04:01:39
select Called_Station_Id,F_User_point,h323_connect_Time from TB_CDR where Calling_Station_Id='0429990001' and Called_Station_Id like '0[1-9]%' and convert (varchar(10),convert(dateTime, h323_connect_Time),112)like'200803%'
上面这条语句查出的数据里面有些是不需要的,如果要把这些不需要的数据筛选出来应该加什么语句?(如筛选0429990003,024990003等等)请专家帮忙看看,谢谢了
...全文
245 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sy4722 2008-04-07
  • 打赏
  • 举报
回复
不好意思,还得麻烦一下.您写的这条语句能够把大多数的"区号+990001"这样的号码找到,但是遇到像"029或0429"等等这样的区号里有9的就不能够筛选出去了 ,再请教下怎么把这样的数据筛选掉呢?谢谢了
sy4722 2008-04-03
  • 打赏
  • 举报
回复
太感谢了 解决了  
pt1314917 2008-04-03
  • 打赏
  • 举报
回复

--哦,写错了

select Called_Station_Id,F_User_point,h323_connect_Time from TB_CDR where Calling_Station_Id='0429990001'
and Called_Station_Id like '0[1-9]%'
and len(substring(Called_Station_Id,charindex('99',Called_Station_Id)+2,len(Called_Station_Id)))>4
and convert (varchar(10),convert(dateTime, h323_connect_Time),112) like '200803%'


sy4722 2008-04-03
  • 打赏
  • 举报
回复
不行啊,没有筛选掉
pt1314917 2008-04-03
  • 打赏
  • 举报
回复

--try:

select Called_Station_Id,F_User_point,h323_connect_Time from TB_CDR where Calling_Station_Id='0429990001'
and Called_Station_Id like '0[1-9]%'
and len(substring(Called_Station_Id,charindex('99',Called_Station_Id)+1,len(Called_Station_Id)))>4
and convert (varchar(10),convert(dateTime, h323_connect_Time),112) like '200803%'
sy4722 2008-04-03
  • 打赏
  • 举报
回复
是041199后面都是4位的数,前面的0411是各地的区号,后面的是固定的6位数以99开头.如010990001,024990002,0411990003等等之类的值筛选出来不要的
pt1314917 2008-04-03
  • 打赏
  • 举报
回复


我们是要把像0411990001这样的数据筛选掉,保留其他的数据.应该怎么写?
------------------------------
那0411990002和04293991150是否去掉?
你这里所谓的“这样的”,到底是什么规律的数据不能要?
sy4722 2008-04-03
  • 打赏
  • 举报
回复
Called_Station_Id这个字段下的有些数据不需要,需要筛选出来.具体的数据是:
Called_Station_Id F_User_point h323_connect_Time

0411990002 0.04 2008/03/21 10:15:57
042913842922224 0.54 2008/03/20 09:46:55
042913898935335 0.09 2008/03/20 09:27:22
04293991150 0.09 2008/03/20 08:25:21
0411990001 0.04 2008/03/17 17:14:52
我们是要把像0411990001这样的数据筛选掉,保留其他的数据.应该怎么写?
dawugui 2008-04-03
  • 打赏
  • 举报
回复
select Called_Station_Id,F_User_point,h323_connect_Time 
from TB_CDR
where Calling_Station_Id='0429990001' and
left(Called_Station_Id,1) = '0' and
cast(substring(Called_Station_Id,2,1) as int) between 1 and 9 and
convert (varchar(6),convert(dateTime, h323_connect_Time),112) = '200803'
pt1314917 2008-04-03
  • 打赏
  • 举报
回复
哪个字段不需要这些?真实数据到底是什么?

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧