no sex country age 1  M   china   12
2  M   china   12
3  F   china   13
4  M   china   12
5  F   china   13把sex country age 同时相同的取出来放在一个新表中,
如:
sex country age
M   china    12
F   china    13

解决方案 »

  1.   

    insert newtable
    select sex,country,age from tablename
    group by sex,country,age
      

  2.   

    select * from t a join t b on a.sex=b.sex and a.country =b.country  and a.age=b.age
      

  3.   

    select * into 新建表 from (select sex,country,age from tablename group by sex,country,age)
      

  4.   

    select distinct sex,country,age from tablename
      

  5.   

    先新建一个表,然后
    inset into 新表
    select sex,country,age from tablename
    group by sex,country,age
    绝对可行!
      

  6.   

    回复人: smiler007(笑一笑) ( ) 信誉:118  2005-03-14 19:55:00  得分: 0  
     
     
       select distinct sex,country,age from tablename
      
     我顶!!赞同!
     
      

  7.   

    如果再加上一个字段统计所选字段相同的个数呢?
    如下:
    no sex country age 1  M   china   12
    2  M   china   12
    3  F   china   13
    4  M   china   12
    5  F   china   13把sex country age 同时相同的取出来放在一个新表中,
    如:
    sex country age  count
    M   china    12   3
    F   china    13   2
      

  8.   

    select * into 新建表 from (select sex,country,age,count(*) as [count] from tablename group by sex,country,age)
      

  9.   

    select distinct sex,country,age 
    into 新表
    from tablename
      

  10.   

    create table newtablename as
       select distinct sex,country,age from tablename