我正在尝试编写一个SQL查询,我必须选择标题,年份并拍摄电影费用并除以每张有价格的电影的价格租金。
PRICE到MOVIE实体是1:M,因此PRICE_CODE是实体MOVIE中的FK。
这是我到目前为止所得到的,但它一直说我的操作员无效。
有人可以帮忙吗?
SELECT movie_title, movie_year, movie_cost
FROM MOVIE
JOIN PRICE
ON movie.price_code = price.price_code
WHERE (movie_cost)/(price_rentfee);
答案 0 :(得分:1)
你很亲密:
SELECT movie_title, movie_year, movie_cost/price_rentfee As "Cost to price ratio"
FROM MOVIE
JOIN PRICE
ON movie.price_code = price.price_code
WHERE COALESCE(price_rentfee, 0) > 0;
如果你有任何机会输了一个拼写错误而且movie_cost
应该movie.cost
和price_rentfee
- price.rentfee
那么它会如下:
SELECT movie_title, movie_year, movie.cost/price.rentfee As "Cost to price ratio"
FROM MOVIE
JOIN PRICE
ON movie.price_code = price.price_code
WHERE COALESCE(price.rentfee, 0) > 0;
答案 1 :(得分:0)
试试这个:
SELECT movie_title, movie_year, (movie_cost)/(price_rentfee) as 'cost'
FROM MOVIE
JOIN PRICE
ON movie.price_code = price.price_code;