Answer the question
In order to leave comments, you need to log in
How to get the number of records in a selection?
how do i count the number of rows in a fetch
SELECT
tab_count.product_id,
tab_count.total,
ocp.status
FROM (SELECT
product_id,
count(product_id) AS total
FROM oc_order_product
GROUP BY product_id
ORDER BY total DESC) AS tab_count,
oc_product AS ocp
WHERE ocp.status = '1' AND ocp.product_id = tab_count.product_id
GROUP BY tab_count.product_id
ORDER BY tab_count.total DESC
Answer the question
In order to leave comments, you need to log in
a separate query, for example:
SELECT count(*)
FROM (SELECT
product_id,
count(product_id) AS total
FROM oc_order_product
GROUP BY product_id
ORDER BY total DESC) AS tab_count,
oc_product AS ocp
WHERE ocp.status = '1' AND ocp.product_id = tab_count.product_id
GROUP BY tab_count.product_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question