# 數學運算子符號

## 支援的運算子

+ 加法 2 + 3 5
- 減法 2 - 3 -1
* 乘法 2 * 3 6
/ 除法 4 /2 2
% 模數 5 % 4 1
^ 指數 2.0 ^ 3.0 8
|/ 平方根 | / 25.0 5
||/ 立方根 || / 27.0 3
@ 絕對值 @ -5.0 5
<< 位元左移 1 << 4 16
>> 位元右移 8 >> 2 2
& 位元 and 8 & 2 0

## 範例

``````select commission, (commission + 2.00) as comm
from sales where salesid=10000;

commission | comm
-----------+-------
28.05      | 30.05
(1 row)``````

``````select pricepaid, (pricepaid * .20) as twentypct
from sales where salesid=10000;

pricepaid | twentypct
----------+-----------
187.00    |    37.400
(1 row)``````

``````select (select sum(qtysold) from sales, date
where sales.dateid=date.dateid and year=2008)
^ ((5::float/100)*10) as qty10years;

qty10years
------------------
587.664019657491
(1 row)``````

``````select sum (pricepaid) as sum_price, dateid,
sum (commission) as sum_comm, (sum (pricepaid) - sum (commission)) as value
from sales where dateid >= 2000
group by dateid order by dateid limit 10;

sum_price | dateid | sum_comm |   value
-----------+--------+----------+-----------
364445.00 |   2044 | 54666.75 | 309778.25
349344.00 |   2112 | 52401.60 | 296942.40
343756.00 |   2124 | 51563.40 | 292192.60
378595.00 |   2116 | 56789.25 | 321805.75
328725.00 |   2080 | 49308.75 | 279416.25
349554.00 |   2028 | 52433.10 | 297120.90
249207.00 |   2164 | 37381.05 | 211825.95
285202.00 |   2064 | 42780.30 | 242421.70
320945.00 |   2012 | 48141.75 | 272803.25
321096.00 |   2016 | 48164.40 | 272931.60
(10 rows)``````