2016-06-12 29 views
1

我正在尝试将items.unit_price,在子查询中将其值增加10%,然后将其显示在另一列中。更改子查询中的值时出现问题

这里是我的代码

select items.title, items.unit_price, items.unit_price as Price_increase 
from artists 
join items 
on items.artist_id = artists.artist_id 
order by price_increase in 
(
    select distinct round(items.unit_price + (items.unit_price * 0.1), 2) as Price_increase 
    from artists 
    where artists.artist_name = "No Rest For The Weary" 
) 
; 
+0

您的标题完全是无稽之谈,修复它,我删除我的downvote。 – peterh

+0

这是更好吗? –

+0

是的,我已经改变了我的downvote。谢谢! – peterh

回答

1

这是你想要的吗?

select i.title, i.unit_price, 
     (case when a.artist_name = 'No Rest For The Weary' 
      then 1.1*i.unit_price else i.unit_price 
     end) as Price_increase 
from artists a join 
    items i 
    on i.artist_id = a.artist_id 
order by price_increase; 
+0

我应该使用子查询。您发布的内容是否属于子查询?因为我真的不知道。 –

+1

*我应该使用子查询* ...这是一个家庭作业问题? – Parfait

+0

这是一个项目,我想我或多或少地知道问题是什么。 –