We have a clickhouse table that stores feedback from users - score (-10 to 10) - weight…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
We have a clickhouse table that stores feedback from users
- score (-10 to 10)
- weight
- user_id
- comment
- trace_id (for which feedback was given)
Write the query to get data to show the Line chart trend of the weighted average feedback
- Assistant
Sure, let's write a SQL query for ClickHouse to calculate the weighted average of feedback scores over time. I'm assuming you have atimestampcolumn in your table to track when the feedback was given. If not, you might need to add one for this kind of analysis.
Here's a simple query that will calculate the weighted average feedback per day:
────────────────────────────────────────────────────────────────────
sqlCopy codeSELECT toDate(timestamp) AS Date, sum(score * weight) / sum(weight) as Weighted_Avg_Score FROM feedback_table GROUP BY Date ORDER BY Date