Level 75
A group by normally transgresses the whole table to arrive at the results. So a limit with a group by I'd avoid. But there are join examples here:
https://laravel.com/docs/5.4/queries#ordering-grouping-limit-and-offset
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello every one please i need help how would I go about this select using Laravel's fluent query builder? I am aware I can use a raw sql query but I would like to avoid that if possible. Any help would be appreciated, thanks in advance!
SELECT SUM(COST) FROM (
SELECT COUNT(STOCK_ID)*PRICE COST
FROM STOCK ST INNER JOIN PRODUCT PDT ON PDT.PROD_ID=ST.PROD_ID
WHERE PROD_NAME='PENCIL' LIMIT 6 GROUP BY STOCK_ID) TB
Please or to participate in this conversation.