[TYPO3-dev] Extbase + group by + having

Jigal van Hemert jigal.van.hemert at typo3.org
Tue Mar 31 22:27:08 CEST 2015


Hi,

On 30/03/2015 18:44, Bernhard Kraft wrote:
> I know it has been asked quite some times. But is there a reason extbase
> does not support the "group by" SQL statement including "having"?

To me it's because extbase tries to select sets of objects. Using a 
GROUP BY clause turns the result set in aggregates of records. Only if 
you do not use aggregate functions one could argue that the result is a 
set of objects where only one is included for each value of the GROUP BY 
clause.

HAVING is to have further limit the result set, but it shouldn't be used 
if it can be handled by WHERE (HAVING is not optimized). It's only 
useful if GROUP BY is used.

> I know sometimes it is possible to adapt the data model and or queries.
> For example to resolve a GROUP BY problem one could look at the
> relations from "the other side" but this does not work in every case.
> Especially if the sorting criteria defined for the relation is different
> from what it should be within the query.

It must really be a very specific situation where you need to paginate 
not objects, but some results of an aggregate query. Such special 
situation may not fit in the normal extbase solution and require a query 
of your own and perhaps a different viewhelper to present the data.

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org



More information about the TYPO3-dev mailing list