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;
熱點內容