我需要打印(显示)由以下代码创建的表的最大值:
SELECT name, SUM(cost)+SUM(DISTINCT stock*cost) AS result
FROM publishers
NATURAL JOIN editions
NATURAL JOIN shipments
NATURAL JOIN stock
GROUP BY name
我尝试过使用DESC但不允许使用它
答案 0 :(得分:2)
SELECT MAX(result) from (SELECT name, SUM(cost)+SUM(DISTINCT stock*cost) AS result FROM publishers NATURAL JOIN editions NATURAL JOIN shipments NATURAL JOIN stock group by name )
如果您只需要result
的最大值,则应该执行此嵌套查询。