'SQL to find Customers redeemed More than one offers (from 2 different customer tables)

This is what I am trying to solve for: Table A has Customers redeeming 1st party offers. Table B has customers redeeming 3rd party offers. I want to see all customers that have redeemed multiple offers (multiple offers can be someone redeeming more than one 1st party offer or more than 1 3pt offers or one first party and one third party offers).

I have written separate queries to identify customers who have redeemed multiple 1P offers and 3P offers, but how do I solve for identifying customers who have redeemed one first party offer and one 3pt offer?

The output should be all the customers that have had more than one offer redemptions.

My query: (same logic goes for 3PT redemptions too)

select distinct customer_id, offer_id

from Table_FirstPartyOffers p

where

p.status = 'CONSUMED'

and p.create_date >='2021-08-01'

AND customer_id IS NOT NULL

) group by 1

having count(offer_id)>1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source