sql中sum
发布时间: 2025-01-22 04:47:15
㈠ 鍦⊿QL涓锛 sum()鍑芥暟镐庝箞鐢锛
璇鍙ヤ负锛
withtemp1(col1)as
(select1col1
unionall
selectcol1+1col1
from
temp1
wherecol1+1<=20
)
selectexp(sum(log(col1)))
fromtemp1;
镓╁𪾢璧勬枡锛
娉ㄦ剰浜嬮”
sql涓娌℃湁涔樻硶鍑芥暟锛屾墍浠ヤ竴鑸鐢锛
logx+logy=logx*y
瀹炵幇鏂瑰纺锛屽厛瀵硅板綍鍙栧规暟log(),铹跺悗sum镵氩悎锛屾渶钖巈xp锛岀粨鏋滃氨鏄璁板綍鐩镐箻镄勭粨鏋溿
SUM鍑芥暟镄勮娉曟槸锛
SELECT SUM(expression )
FROM tables
WHERE predicates;
琛ㄨ揪寮忓彲浠ユ槸涓涓鏁板煎瓧娈垫垨鍏寮忋
渚嫔傦纴鍙鑳芥兂鐭ラ亾钖埚苟鍏ㄤ綋锻桦伐镄勮柂閲戞婚濈编鍏冧互涓婏纴鍏惰柂閰鏄25,000/骞
SELECT SUM(salary) as "Total Salary"
FROM employees
WHERE salary > 25000;
热点内容