Max across multiple categories

Database
Highlighted
New Member

Max across multiple categories

Hey all,

 

This mabye be an exceptionally easy question but I still need some help.

 

I've a database that pull Social media contact data. There is 32 rows of necessary output (including date, time, handle etc)

 

What I need to see relates to two output items, Conversation Ref and Post counter (every convo will have a ref and the post counter will rise based on subscquent posts to the same convo). I am looking to see data relating to the last post on a particluar convo ref, I am using a max however this doesnt seem to work and I am getting duplicate convo refs.

 

Any ideas or suggestions that might help me?

 

Thanks in advance

1 REPLY
Junior Contributor

Re: Max across multiple categories

Something like

select *
from tab       
qualify 
   row_number()
   over (partition by reference         -- for each conversation
         order by postcounter desc) = 1 -- latest post