表如下:
id  city  date  
1   武汉  2007-1-1  
2   武汉  2007-1-2
3   武汉  2007-6-1
4   深圳  2007-2-4
5   广州  2007-4-5
6   广州  2007-4-6
7   深圳  2007-2-5
8   武汉  2007-6-2
.....我想查询结果按如下显示:1   武汉  2007-1-1  
2   武汉  2007-1-2
3   武汉  2007-6-1
8   武汉  2007-6-2
4   深圳  2007-2-4
7   深圳  2007-2-5
5   广州  2007-4-5
6   广州  2007-4-6按城市分组,组中按照日期先后排列..

解决方案 »

  1.   

    select * from table order by city,date
      

  2.   

    select * from tb order by city,date
      

  3.   

    select * from tablename order by city,date
      

  4.   

    select * from tablename
    order by city desc,date
      

  5.   

    create table table_1(id int,city varchar(10),date datetime)
    insert into table_1
    select 1,'武汉','2007-1-1'
    union all select 2,'武汉','2007-1-2'
    union all select 3,'武汉','2007-6-1'
    union all select 4,'深圳','2007-2-4'
    union all select 5,'广州','2007-4-5'
    union all select 6,'广州','2007-4-6'
    union all select 7,'深圳','2007-2-5'
    union all select 8,'武汉','2007-6-2'select * from table_1
    order by city desc,date
      

  6.   

    select * from table order by city,date
      

  7.   

    select * from tablename
    order by city desc,date
    ----------------------------------
    转载楼上的可以吗呵呵,接分
      

  8.   

    为什么要用到DESC这个参数,是因为楼主需要的城市排序而定
      

  9.   

    select * from tablename
    order by city desc,date
    ----------------------------------
    转载楼上的可以吗呵呵,接分
    ----------------------------------
    需要支付一块你那里的特产(七色彩云)邮寄给我,吼吼!