Sql Server : How to use an aggregate function like MAX in a WHERE clause

前端 未结 6 1189
灰色年华
灰色年华 2020-12-03 04:48

I want get the maximum value for this record. Please help me:

SELECT rest.field1 
    FROM mastertable AS m
    INNER JOIN  (
        SELECT t1.field1 field1         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 05:19

    yes you need to use a having clause after the Group by clause , as the where is just to filter the data on simple parameters , but group by followed by a Having statement is the idea to group the data and filter it on basis of some aggregate function......

提交回复
热议问题