oracle - oracle中如何对列数据进行注释?
问题描述
客人希望根据星级显示度假村的度假村 ID、名称和评论。
度假村显示评论如下
如果评分在 5.0 到 4.5 之间,则将评论显示为“优秀度假村”
如果评分介于 4.4 到 4.0 之间,则将评论显示为“非常好的度假村”
否则显示 'Good Resort' 。将此结果的别名命名为 Comments。
根据度假村 ID 对结果进行排序。
解决方案
如果我正确阅读了模型,那么
- 计算平均评分
- 把它和
resort
桌子连在一起
with ratings as
(select resort_id,
round(avg(star_rating), 1) rating
from resort
group by resort_id
)
select
r.resort_id,
r.resortname,
case when c.rating between 4.5 and 5.0 then 'Excellent'
when c.rating between 4.0 and 4.4 then 'Very good'
else 'Good'
end comment
from resort r join ratings c on r.resort_id = c.resort_id
推荐阅读
- python - PyQt5 QWebEngine 对 Javascript 的错误渲染
- python - 我们如何在 sympy 中分离方程较小的分离方程
- wordpress - 首页上的WordPress分页不起作用
- jenkins - 使用“kubectl apply”命令滚动更新
- jenkins - 是否可以为 jenkins github 组织构建设置构建丢弃选项?
- javascript - 如何防止操作覆盖覆盖材料表中的可编辑 onRowAdd 按钮?
- python - 如何替换目录中每个文件中的字符串
- c# - 启用可靠会话时 WCF ContractFilter 不匹配
- ruby-on-rails - 参数数量错误 - resque
- java - 以编程方式提取方法的内容