表A(id,name,regedate)
表B(id,groupid)
表C(id,name)
求:
1     求出A表中每个月的注册用户,regedate格式是yyyy/mm/dd
2    求出A表中所有姓名相同的用户
3    A 表中有相同名字的用户,把相同的选出来放入C表中
4    A 表中姓名相同的id,保留注册最大时间的用户写出sql,谢谢

解决方案 »

  1.   

    求出是指求出有多少件吗?
    have a try 
    1 select substr(regedate,1,7), count(1) from A group by substr(regedate,1,7)
    2 select name, count(1) from A group by name
    3 insert into C(id, name) select a.id, a.name fron A a where (select count(1) from A where name=a.name) > 1
    4 select a.id, a.regedate from A where a.regedate = (select max(regedate) from A where name = a.name)