Следите за новинками
в нашем Telegram канале. Жми, чтобы подписаться:)
⊗pyPmDBSu 117 of 128 menu
◀ ▶

Sum of field values ​​in SQL in Python

To find the sum of the values ​​of one field (column), you should apply the SUM function.

Let's find the sum of all values ​​of id:

query = "SELECT SUM(id) FROM users"

The result of the executed code:

{'SUM(id)': Decimal('21')}

Find the sum of all users' salaries.

Find the sum of all user ages.

Find the sum of salaries of users whose age is greater than or equal to 25.

← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline