我现在想取出这样的数据:去ip段(前两部分)和对应的ip段
应该是
我现在想取出这样的数据:取ip段(前两部分)和对应的ip段
应该是
我现在想取出这样的数据:取ip段(前两部分)和对应的ip段
解决方案 »
- 删除重复记录
- Sql ‘20010203’ 转成 20010203 04:05:06.789'
- 导入文本数据,为什么{CR}$${CR}这样的分隔符不能使用呢
- 急,请问数据库中的model,msdb,northwind,pubs,tempdb这些数据库有什么用处吗?
- 于在sqlserver中导入access问题
- (vfp6.0)列表框中有些文字太长了我希望当某个选项获得焦点时这些文字可以超出列表框长度突出显示请问应该怎样做?
- 能否在服务器上,用一条SQL语句在不同的数据库间导数据?
- 一个触发器的写法,高手请进
- ORACLE异库链接
- 音频格式在数据库中的存取
- 一个SQL
- 啊菜求一简单的SQL语句。
([id] int,[ip] varchar(20))insert @t
select 1,'141.30.217.10' [union] all
select 2,'141.30.217.10' [union] all
select 3,'202.110.36.42' [union] all
select 4,'202.110.36.42' [union] all
select 5,'211.158.67.206' [union] all
select 6,'218.1.114.162' [union] all
select 7,'218.1.114.18' [union] all
select 8,'218.1.186.195' [union] all
select 9,'218.12.3.114' [union] all
select 10,'218.13.24.80'
select * from @tselect [ip]=parsename(ip,4)+'.'+parsename(ip,3),count(*)
from @t
group by parsename(ip,4)+'.'+parsename(ip,3)ip
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------
141.30 2
202.110 2
211.158 1
218.1 3
218.12 1
218.13 1
--自己写了个复杂点的,也贴上好了。
select left(ip,charindex('.',ip))+left(right(ip,len(ip)-charindex('.',ip)),charindex('.',right(ip,len(ip)-charindex('.',ip)))-1),count(*)
from ipinfo
group by left(ip,charindex('.',ip))+left(right(ip,len(ip)-charindex('.',ip)),charindex('.',right(ip,len(ip)-charindex('.',ip)))-1)
,count(1) as 'count'
from (
select Id
,left(Ip,charindex('.',Ip,charindex('.',Ip)+1)-1) as 'Ip'
from IpInfo
)t
group by Ip