select top 10 remoteip from table_name where localmac=""
to dzbswl(白雪儿) 假设有好多localmac且每天都不同呢?怎么读出有几个不同的localmac呢?
如果使用SQL7就写一个存储过程 declare @cName varchar(40) Create Table #T_table_name ( localmac varchar(40), remoteip varchar(40) ) declare cName cursor For select distinct localmac FROM table_name open cName fetch cName Into @cName while @@fetch_status=0 begin insert into #T_table_name select top 10 localmac,remoteip from table_name where localmac=@cName order by remoteip desc fetch cName Into @cName end close cName deallocate cName select * From #T_table_name
select top 10 remoteip from table_name where localmac in (select distinct localmac from table_name)
假设有好多localmac且每天都不同呢?怎么读出有几个不同的localmac呢?
declare @cName varchar(40)
Create Table #T_table_name (
localmac varchar(40),
remoteip varchar(40)
)
declare cName cursor For
select distinct localmac FROM table_name
open cName
fetch cName Into @cName
while @@fetch_status=0
begin
insert into #T_table_name select top 10 localmac,remoteip from table_name where localmac=@cName order by remoteip desc
fetch cName Into @cName
end
close cName
deallocate cName
select * From #T_table_name