--统计函数
create function getcitynum(
@province varchar(10)
)returns int
as
begin
  return((select count(*) from tb where province=@province))
end
go--查询
select province,dbo.getcitynum(province) citynum,city  from tb