我被要求写一份声明,其中包含以下内容:"通过权力2增加资金然后除以2.将结果四舍五入到#34;。
这是table
这是我到目前为止所得到的
SELECT event_id, place, money,
POWER(money,2)/2 as x,
ROUND(x,0) as 'new money'
FROM PRIZE
ORDER BY event_id, place;
我无法弄清楚如何在同一声明中对x进行舍入 - 我猜这个值还没有被创建?
由于
答案 0 :(得分:1)
只需嵌套函数调用。
SELECT event_id, place, money,
ROUND(POWER(money,2)/2,0) as 'new money'
FROM PRIZE
ORDER BY event_id, place;
答案 1 :(得分:0)
你可以使用子查询,
SELECT *, ROUND(x,0) as 'new money'
FROM (
SELECT *, POWER(money,2)/2 as x from PRIZE
) as TABLE1
ORDER BY event_id, place