|
--Test Data
create table t (id int identity (1,1), ip nvarchar (20), sid char (1))
insert t (ip, sid)
select '127.0.0.1', 'a' union all
select '127.0.0.2', 'a' union all
select '127.0.0.3', 'a' union all
select '127.0.0.1', 'a' union all
select '127.0.0.4', 'b' union all
select '127.0.0.3', 'a' union all
select '127.0.0.5', 'c' union all
select '127.0.0.6', 'd'
select count (distinct ip) from t where sid = 'a'
drop table t |
|