sql - 将文本转换为数字以进行客户满意度调查
问题描述
我有客户满意度反馈,如好、差、优秀等,我想分配一个数值,如优秀 = 5、好 = 4、中性 = 2、不满意 = 0 然后按类别对值求和
这个查询我只需要以“选择”开头
按月分组 优秀 400 优秀 500
解决方案
用例当
select sum(case when satisfaction ='Excellent' then 5
when satisfaction ='Good' then 4
when satisfaction ='Neutral' then 2
when satisfaction ='Dissatisfied' then 0 end) as satisfaction_val
,category from table_name group by category
推荐阅读
- javascript - 运行我的 react 应用程序的生产版本时,res.data 返回 html 而不是令牌
- laravel - 当表单提交在 Laravel 中失败时如何保留输入字段中的值
- php - 从 Base64 解码添加文件时出现错误“指定文件上传测试失败”
- exceljs - 如何使用 exceljs 定义范围的名称?
- tensorflow - tf.dataSync() 不会以可读形式从 BlazeFaceModel 返回张量
- reactjs - 将函数传递给自定义钩子
- python - 从在 android TV 中播放应用程序中获取时间
- r - Quanteda 随时间改变术语的相对频率
- c# - 打破1方法创造2
- laravel - 将自定义项添加到 eloquent 集合