Ordering posts by the aggregated count of likes and saves using Ecto

My SQL skills are a bit rusty, and honestly were never the absolute best, so I’m at a bit of a loss as to how to do this in one go.

What I have is three tables, Prompts, LikedPrompts, and SavedPrompts

LikedPrompts and SavedPronts are simple tables with just the user_id and prompt_id as columns.

What I’m looking to do is to return a list of Prompts in a descending order where the number of likes and saves for each prompt have been added together.

So, for example, if Prompt #1 has 20 saves and 10 likes, but Prompt #2 has 5 saves and 50 likes, the results will be [Prompt2, Prompt1] as Prompt2 will have an aggregated score of 55 while Prompt1 will have an aggregated score of 30.

Can anyone help me figure out what this query looks like?