我只想根据 id,道路代码,道路名称,病害大类 这几个字段分组,不能要日期,但我又必须依日期排倒序,sql语句该怎么写?我的sql 语句是这样的:
[b]strsql= "select id,道路代码,道路名称,病害大类 from " + tableName + " where 病害大类 like '" + xunsifl + "' and 修复完工='是' group by id,道路代码,道路名称,病害大类, order by 采集日期 desc" ;

解决方案 »

  1.   


    strsql= "select id,道路代码,道路名称,病害大类,采集日期 from " + tableName + " where 病害大类 like '" + xunsifl + "' and 修复完工='是' group by id,道路代码,道路名称,病害大类, order by 采集日期 desc" ;
    往select里面加一个采集日期就Ok了
      

  2.   

    上面有一个错误 不好意思多了个,号
     group by id,道路代码,道路名称,病害大类, 
      

  3.   

    谢谢你、!但是只要
    select id,道路代码,道路名称,病害大类,采集日期 …………
    查询语句中用到了“采集日期”,就必须得在group by 中出现啊!