Here is how my data is configured in my order table:
I have 3 fields: ORDER_ID, that is the unique field per ORDER (only appears once in the whole table), USER_KEY, that is the unique field per BUYER (buyers can place multiple orders and can appear multiple times in the order table), and FRUIT, that identifies the item that has been bought per order.
I need to identify the buyers (USER_KEY), that have purchases multiples of the same products.
I have the following query to identify these buyers:
select
t.user_key from temp t
inner join (
SELECT user_key,
Count(order_id) as [Minimum of 2 Count] from temp group by user_key, fruit
) it on t.user_key = it.user_key and it.[Minimum of 2 Count] > 1
group by t.user_key;
This query however does not work in SNOWFLAKE. Does anyone know how I can tweak the syntax of this query to work in Snowflake?
Thank you!
