create table ta(num int, win varchar(100))
insert ta select '2005001', '01 02 06 34 11 32 08'
union all select '2005002', '03 02 06 34 11 32 08'
union all select '2005003', '22 34 12 32 09 07 23'
union all select '2005004', '20 21 34 33 09 08 06'
union all select '2005005', '05 08 23 11 14 33 35'
--查询
select id=identity(int) into #tt from syscolumns
select wincode, times=count(1)
from (
select num, wincode=substring(win, id, 2)
from ta, #tt
where id<=len(win)
and substring(' '+win, id, 1)=' ' )t
group by wincode--清除
drop table #tt
drop table ta

解决方案 »

  1.   

    --filebat(Mark) 
    没太看懂
    -.-程序这行 真的需要天分的
      

  2.   

    --to 楼上:
    create table ta(num int, win varchar(100))
    insert ta select '2005001', '01 02 06 34 11 32 08'
    union all select '2005002', '03 02 06 34 11 32 08'
    union all select '2005003', '22 34 12 32 09 07 23'
    union all select '2005004', '20 21 34 33 09 08 06'
    union all select '2005005', '05 08 23 11 14 33 35'
    --查询
    select id=identity(int) into #tt from syscolumns
    select top 5 *
    from(
    select wincode, times=count(1)
    from (
    select num, wincode=substring(win, id, 2)
    from ta, #tt
    where id<=len(win)
    and substring(' '+win, id, 1)=' ' )t
    group by wincode
    )tt
    order by times desc--清除
    drop table #tt
    drop table ta
      

  3.   

    嘻嘻,谢谢楼上的好人,我是菜鸟看不大懂,得收藏了慢慢琢磨了。急着赶任务,自己用了一个土办法,就是每次都select top 1,然后查一条便删除一条,总共查5次,呵呵,笨人办法,不会有错误吧,就是执行效率不高,不管了。:P
      

  4.   

    to:  filebat(Mark) 阁下构思巧妙, 收藏 学习了!