Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT temp2.customer_id, it_temp2.product_id, temp2.order_date
- FROM SALES_ORDER temp2, ITEM it_temp2
- WHERE (
- SELECT COUNT(temp.order_id)
- FROM SALES_ORDER temp, ITEM it_temp
- WHERE temp.customer_id = temp2.customer_id
- AND ABS(DATEDIFF(DAY, temp.order_date, temp2.order_date)) <= 7
- AND temp.order_id != temp2.order_id
- AND it_temp.order_id = temp.order_id
- AND it_temp.product_id = it_temp2.product_id
- ) > 0
- AND it_temp2.order_id = temp2.order_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement