I am working with a large data table. I want to check the individual items with their destination and the count of destinations if there are more than 1 destination for a given item.
So in the below image, in my result, I should not get Items Grapes and Rice since there is only one destination for them. I want to filter by the destination as well. I need to remove the items which are going to the same destination. So here, only Apple and their respective destinations are the ones I need. Orange should be removed because its going to the same destination.
The query I have written is below. However it does not serve the purpose.This does not filter out same destinations. Any help please ?
select Item,
listagg(Destination, ',') within group (order by Destination) as Destination
from ProductsTable
group by Item
Best Answer