oracle中如何对列数据进行注释?

how to give comments to column data in oracle?

客人想要根据度假村的星级显示度假村 ID、名称和评论。

度假村评价显示如下

如果评分介于 5.0 到 4.5 之间,则将评论显示为 'Excellent Resort'

如果评分在 4.4 到 4.0 之间,则将评论显示为 'Very Good Resort'

否则显示 'Good Resort'。为这个结果起一个别名作为 Comments。

根据度假村 ID 对结果进行排序。

如果我没看错模型,那么

  • 计算平均评分
  • 加入 resort table

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
select resortid, resortname, 
   case when starrating between 4.5 and 5.0 then 'Excellent Resort' 
        when starrating between 4.0 and 4.4 then 'Very Good Resort'
        else 'Good Resort'
    end as comments
 from resort
 order by resortid;

这有效