select grocery_item,
PRICE_IN_2000,
ESTIMATED_PRICE_IN_2025,
ROUND((ESTIMATED_PRICE_IN_2025/PRICE_IN_2000-1)*100,2) ||'%' as "MY OUTPUT"
from grocery_prices
然后得到
GROCERY_ITEM PRICE_IN_2000 ESTIMATED_PRICE_IN_2025 MY OUTPUT
------------------------------ ------------- ----------------------- -----------------------------------------
DOZEN EGGS 1.02 1.78 74.51%
LOAF OF WHITE BREAD 0.88 3.31 276.14%
POUND OF BUTTER 2.72 7.36 170.59%
GALLON OF MILK 2.7 5.65 109.26%
然后我该用什么命令只显示MY OUTPUT 最大的那一列呢?(也就是276.14那一列)
where "MY OUTPUT"=Any( select max((ESTIMATED_PRICE_IN_2025/PRICE_IN_2000-1)*100)||'%' from grocery_prices);
改不出来了,求大神帮帮我~~~~
------解决方案--------------------
- SQL code
select grocery_item, PRICE_IN_2000, ESTIMATED_PRICE_IN_2025, ROUND((ESTIMATED_PRICE_IN_2025/PRICE_IN_2000-1)*100,2) ||'%' as "MY OUTPUT"from grocery_priceswhere ESTIMATED_PRICE_IN_2025/PRICE_IN_2000=(select max(ESTIMATED_PRICE_IN_2025/PRICE_IN_2000) from grocery_prices)--加一句
------解决方案--------------------
- SQL code
-->tryselect top 1 grocery_item, PRICE_IN_2000, ESTIMATED_PRICE_IN_2025, ROUND((ESTIMATED_PRICE_IN_2025/PRICE_IN_2000-1)*100,2) ||'%' as "MY OUTPUT"from grocery_pricesorder by ROUND((ESTIMATED_PRICE_IN_2025/PRICE_IN_2000-1)*100,2) desc
------解决方案--------------------
单纯你的问题,用1楼的可以了,如果你想从你那个语句着手,那要改成这样:
- SQL code
select grocery_item, PRICE_IN_2000, ESTIMATED_PRICE_IN_2025, ROUND((ESTIMATED_PRICE_IN_2025/PRICE_IN_2000-1)*100,2) ||'%' as "MY OUTPUT" from grocery_priceswhere "MY OUTPUT">=Any( select max((ESTIMATED_PRICE_IN_2025/PRICE_IN_2000-1)*100)||'%' from grocery_prices);