Many of my friends as well as previous workplaces emphasized use of ORMs over working with SQL directly. I've been exposed to Laravals ORM (Eloquent), Silverstripe's ORM, Active record, and Entity Framework (kinda).

Now I'm writing SQL code that uses the OVER clause quite frequently and wondering if that were possible from typical ORMs as mentioned above. Do ORMs make the OVER clause accessible - or are there any ORMS that do that?

If so, would those ORMs make accessible all the OVER clause's aruguments (which I guess would be database specific)?


1 Answer 1


Not really.

While some ORMs may very well be able to utilize windowing functions you yourself write none of them will be able to generate window functions. ORMs map data to data. They are an Object Oriented to relational data-translation layer. Window functions are a data-processing feature. It's a declarative way to process a result set, they run in the last-step of result-set generation, docs:

If the query contains any window functions, these functions are evaluated after any grouping, aggregation, and HAVING filtering is performed. That is, if the query uses any aggregates, GROUP BY, or HAVING, then the rows seen by the window functions are the group rows instead of the original table rows from FROM/WHERE.

At the point a Window Function works, the authors of an ORM may as well map the syntax into their own result-set processing features.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.