Difficulties getting a nested query to work

Posted 1 year ago by lmartins

Hi,

I need to convert a query that is designed to find the higher price from two dimensions matrix (width/height).

On SQL is a fairly trivial query:

SELECT
    price
FROM
    matrices
    INNER JOIN (
            SELECT
                price_group_id,
                max_width
            FROM
                matrices
            WHERE
                price_group_id = 1
                AND max_width >= 74
            ORDER BY
                max_width
            LIMIT 1) AS t ON matrices.max_width = t.max_width
        AND matrices.price_group_id = t.price_group_id
    WHERE
        matrices.max_height >= 84
    ORDER BY
        matrices.max_height
    LIMIT 1

But I'm not being able to convert this into something Laravel can consume.

Thanks so much for any help you may provide.

Please sign in or create an account to participate in this conversation.