Which is the least expensive aggregate function in the absence of ANY()
I usally use MAX() or MIN() if a DBMS hasn't an ANY() aggregate function.
Is there something less expensive in mySQL and MS-SQL?
MySQL does not need an ANY() aggregate.
if I do a
SELECT field1, field2, SUM(field3) FROM table1
GROUP BY field2
Microsofts T-SQL will complain but
MySQL will just silently execute
SELECT whatever(field1), field2, SUM(....
Which of course is way faster than SELECT max(field1), field2, SUM(.... GROUP BY field2
MySQL supports ANY
, but SELECT ANY(field1) ...
doesn't work because ANY
is an operator similar to IN
and ALL
.
see: http://dev.mysql.com/doc/refman/5.0/en/any-in-some-subqueries.html
I love MySQL
There is no ANY aggregate in ANSI SQL-92
There is the ANY qualifier to match SOME and ALL
MIN and MAX are proper aggregates... completely unrelated and shouldn't be compared
Edit:
Only MySQL has this ambiguity of an "ANY" aggregate: SQL Server, Sybase, Oracle, PostGres do not. See Do all columns in a SELECT list have to appear in a GROUP BY clause
MIN和MAX的价格相当(昂贵)。
链接地址: http://www.djcxy.com/p/30502.html上一篇: 您无法在FROM子句中为更新指定目标表