SQL语句如下:
Select Max(MMFWorkID),Max(TaskID),Max(MMFname),ModeL,sum(BeginWeight),sum(EndWeight), 
sum(loss),sum(qty),max(batch),max(dept),max(editer),MAX(EDITDATE) 
from MMFWork 
Where 1=1  and TaskID like '%%' 
and MMFName like '%%' and Model like '%%' 
and Batch like '%%'  Group by ModeL order by editdate desc去掉order by editdate可以运行,但是我需要对日期进行排序,提示editdate未包含在聚合函数中,也未在group子句中

解决方案 »

  1.   

    Select Max(MMFWorkID),Max(TaskID),Max(MMFname),ModeL,sum(BeginWeight),sum(EndWeight), 
    sum(loss),sum(qty),max(batch),max(dept),max(editer),MAX(EDITDATE) 
    from MMFWork 
    Where 1=1  and TaskID like '%%' 
    and MMFName like '%%' and Model like '%%' 
    and Batch like '%%'  Group by ModeL order by MAX(EDITDATE)  desc
      

  2.   

    Select Max(MMFWorkID),Max(TaskID),Max(MMFname),ModeL,sum(BeginWeight),sum(EndWeight), 
    sum(loss),sum(qty),max(batch),max(dept),max(editer),MAX(EDITDATE) editdate1 
    from MMFWork 
    Where 1=1  and TaskID like '%%' 
    and MMFName like '%%' and Model like '%%' 
    and Batch like '%%'  Group by ModeL order by editdate1 desc