SELECT MAX(sf_time2) AS sf_time2 FROM (SELECT MAX(sf_time1) AS sf_time1, sf_time2 FROM Zd_Sf GROUP BY sf_time2)如题,这句嵌套在SQL中没问题,一放到VB中就提示“)附近有错误”不知错误在哪里请哪位大哥指点一下谢谢

解决方案 »

  1.   

    strsql="SELECT MAX(sf_time2) AS sf_time2 FROM (SELECT MAX(sf_time1) AS sf_time1, sf_time2 FROM Zd_Sf GROUP BY sf_time2)"
      

  2.   

    dim Str as String
    dim Conn as adodbc.connectiong
    dim Rs as adodbc.recordset
    Str="SELECT MAX(sf_time2) AS sf_time2 FROM (SELECT MAX(sf_time1) AS sf_time1, sf_time2 FROM Zd_Sf GROUP BY sf_time2)" 
    Conn.open 你数据库的连接字符串
    set Rs=Conn.excute(Str)
      

  3.   

    SELECT MAX(sf_time2) AS sf_time2 FROM (SELECT MAX(sf_time1) AS sf_time1, sf_time2 FROM Zd_Sf GROUP BY sf_time2) as tmp
      

  4.   

    SELECT MAX(sf_time2) AS sf_time2 FROM (SELECT MAX(sf_time1) AS sf_time1, sf_time2 FROM Zd_Sf GROUP BY sf_time2) as tmp