Skip to content
Advertisement

SQL – Customer Satisfaction Impact (Subquery needed?)

I’ve been having some SQL troubles trying to add a new column to my table which I believe relies on sub-queries to work.

Below I’ve shared a link to a Google Sheet with some example data to demonstrate what I’m trying to achieve. https://docs.google.com/spreadsheets/d/1qaWZg4BEs8xOxG3jNZwKRcaOGfMiMtCb15IU3FQ9W0o/edit?usp=sharing

Very basic layout I have is:

I understand the above will get me the satisfaction score for each row of team_member,language,channel,month. I’m trying to add new columns to the end of this which could get me:

  • sum(total_customers) rolled up by language
  • Satisfaction_Score for the supported language by team_member

Which I could then use to calculate satisfaction impact, which is laid out like:

(team member satisfaction score-language satisfaction score)*(team member total customers/language total customers)

I sadly haven’t even got close to the answer, hoping a wizard here might know how it could be done?

Advertisement

Answer

You can use window functions:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement