Find the top 3 most frequent product combinations bought together
Вставка
- Опубліковано 7 лют 2025
- In this video i have explained how to Find the top 3 most frequent product combinations bought together .
dataset and solution:-
drive.google.c...
SELF JOIN VIDEO :- • Joins (part 3 Cross jo...
If you are interested in more such Lectures you can enroll in our upcoming course of Data Analytics .
For that contact me directly:-
On call : +91 6396569313
On WhatsApp : +91 9870896958
Connect with me on
LinkedIn - / pragya-rathi-8025b526a
WhatsApp Group - chat.whatsapp....
Topmate - topmate.io/let...
thx mam plz continue this series
For sure
Please share in another method also - thanks
Sure 👍
WITH product_pairs AS (
SELECT
A.order_id,
CONCAT(A.product_id, '-', B.product_id) AS product_pair
FROM order_details A
JOIN order_details B
ON A.order_id = B.order_id
AND A.product_id < B.product_id
),
pair_counts AS (
SELECT
product_pair,
COUNT(*) AS counts
FROM product_pairs
GROUP BY product_pair
),
ranked_pairs AS (
SELECT
product_pair,
counts,
ROW_NUMBER() OVER (ORDER BY counts DESC) AS rn
FROM pair_counts
)
SELECT product_pair, counts
FROM ranked_pairs
WHERE rn