So I have two tables, let’s call them Orders and Customers. In the orders table there are duplicate records which I need to identify. I am attempting to select event_key and order_item while doing an inner join on the event_key, and also selecting the order_key and customer_key from the other table that has the event_key in common.
Orders table
- Event_key
- Order_item
Customers table
- Event_key
- Order_key
- Customer_key
By doing this, I’m seeing more duplicate entries than there actually are. To put it simply, I just want to find the duplicates on the orders table, and select the associating order and customer keys from the customers table.
Select count(*) as count from orders_tbl o
Inner join customers_tbl c
on o.event_key = c.event_key
group by o.event_key, o.order_item, c.order_key, c.customer_key
where o.event_key = 1 and o.order_item = 16 and c.order_key = 2 and c.customer_key = 6
How do I go about this?