我的问题是:管理层建议根据评级使用以下百分比来提高电影价格:
‘14A’, 25%;
‘18A’, 15%;
‘A’, 10%;
all others 5%.
创建一个列表,显示电影名称,评级类型,当前租金金额和修订后的租金金额。列标题应为“电影名称”,“评级”,“当前租金价格”,“新租金价格”。当前和新的租赁价格必须格式化为2位小数的货币。按评级对列表排序。如果某个类别中有多个影片,则按影片名称排序为辅助排序。
SELECT Name AS "Movie Name", Rating, RentalAmount AS "Rental Amount",
TO_CHAR(RentalAmount * 1.25, '999.99') AS "Revised Amount"
FROM Movies
ORDER BY Rating , Name;
答案 0 :(得分:1)
此查询根据“评分”增加“RentalAmount”的值:
SELECT Name AS "Movie Name", Rating, RentalAmount AS "Current Rental Price",
TO_CHAR(RentalAmount*decode(Rating, '14A', 1.25, '18A', 1.15, 'A', 1.1, 1.05), '999.99') AS "New Rental Price"
FROM Movies
ORDER BY Rating, Name