>>If you known that on the group the expression is constant, then
>>min=max=any and these are equals:
>>
>>SELECT item,MIN(exp) FROM test GROUP BY item
>>SELECT item,MAX(exp) FROM test GROUP BY item
>>SELECT item,exp FROM test GROUP BY item,exp
>>SELECT item,exp FROM test GROUP BY exp,item
>>
>>set engine 70
>>SELECT item,exp FROM test GROUP BY item
>>
>>
>>This is a very special case,
>>and a lot of times it conceals a bad planning of the database;
>>then it is difficult to justify the implementation of ANY()
>>
>
>Actually, I think this situation comes up most when you want to select several fields from a parent along with some information from a child. For example:
>
>
>SELECT Customer.CustomerID, CompanyName, MAX(OrderDate) ;
> FROM Customer ;
> JOIN Order ;
> ON Customer.CustomerID = Order.CustomerID ;
> GROUP BY CustomerID
>
>
>In this case, of course, either solution--adding the field to the GROUP BY or wrapping it with MAX()--works.
>
>Tamar
mmmm...
I don't agree, this SQL syntax is wrong for me.
The exact declaration of the request in SQL syntax should to be:
SELECT Customer.CustomerID, CompanyName, MAX_OrderDate ;
FROM Customer ;
JOIN (SELECT CustomerID,MAX(OrderDate) MAX_OrderDate FROM Order GROUP BY CustomerID) Order;
ON Customer.CustomerID = Order.CustomerID
Of course, every SQL engine can or cannot to be able of to execute the declaration
with a fast or slow plan, but this is out of the SQL syntax scope.
Fabio