I can't use NTILE() because I'm currently on MYSQL 5.7 so I was wondering how would I go about converting this to be usable in 5.7 without NTILE. Here's the query I'd like to convert:
SELECT
clientid,
ntile(4) over (
order by
last_order_date
) AS `rfm_recency`,
ntile(4) over (
order by
count_order
) AS `rfm_frequency`,
ntile(4) over (
order by
avg_amount
) AS `rfm_monetary`
FROM
(
SELECT
`clientid`,
MAX(`date`) AS `last_order_date`,
COUNT(`id`) AS `count_order`,
AVG(`price`) AS `avg_amount`
FROM
`design`
GROUP BY
`clientid`
) AS t
) AS p```