Reputation: 747
select customer_id, currency, price
from sales_table
customer_id currency price
1001 CHF 50
1001 EUR 35
1002 EUR 40
1003 AUD 25
I have hundreds of thousands of transactions in the table. How can I do a select clause that only returns the customers who have paid in two different currencies? In this case, the select statement should return customer_id 1001.
Upvotes: 0
Views: 37
Reputation: 5697
select customer_id
from sales_table
group by customer_id
HAVING count(distinct currency) = 2 // or >1 or whatever
Upvotes: 2