我想获得此记录的最大值.请帮帮我:
SELECT rest.field1 FROM mastertable AS m INNER JOIN ( SELECT t1.field1 field1,t2.field2 FROM table1 AS T1 INNER JOIN table2 AS t2 ON t2.field = t1.field WHERE t1.field3=MAX(t1.field3) -- ^^^^^^^^^^^^^^ Help me here. ) AS rest ON rest.field1 = m.field
解决方法
您可以使用子查询…
WHERE t1.field3 = (SELECT MAX(st1.field3) FROM table1 AS st1)
但是我实际上将它从where子句移到join语句中,作为AND子句的AND.