Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
Analyze Feedback by Channel Segment
00:00
5 left

Analyze Feedback by Channel Segment

MediumSQL · PostgreSQL

Problem

You are given customer feedback submitted across DISH touchpoints such as the MyDISH app, chat, phone, and web. Write a PostgreSQL query that returns feedback performance by channel, product_name, and region_name for feedback submitted in Q1 2024. For each combination, show the total number of feedback records, average rating rounded to 2 decimals, counts of positive and negative feedback based on rating, and rank the combinations within each channel by lowest average rating so the most problematic segments appear first. Only include groups with at least 2 feedback records.

Output details

  • Return columns in this order: channel, product_name, region_name, feedback_count, avg_rating, positive_count, negative_count, issue_rank.
  • Treat ratings >= 4 as positive and ratings <= 2 as negative.
  • Use an inclusive lower bound of 2024-01-01 and an exclusive upper bound of 2024-04-01.
  • Treat NULL ratings as counted feedback, excluded from the average, and neither positive nor negative.
  • Rank within each channel by avg_rating ascending, then feedback_count descending, product_name ascending, and region_name ascending.
  • Sort final rows by channel ascending, issue_rank ascending, product_name ascending, and region_name ascending.

Schema

feedback
ColumnTypeDescription
feedback_idPKINTUnique feedback record identifier
customer_idINTCustomer who submitted the feedback
product_idINTReferenced product identifier
submitted_atDATEDate the feedback was submitted
channelVARCHAR(50)Feedback channel such as MyDISH App, Chat, Phone, or Web
ratingINTCustomer rating on a 1 to 5 scale
comment_textTEXTOptional free-text feedback comment
products
ColumnTypeDescription
product_idPKINTUnique product identifier
product_nameVARCHAR(100)DISH product or service name
customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
region_nameVARCHAR(50)Customer region
Tablesfeedbackproductscustomers
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.