SQL Running Total: How To Calculate a Running Total in SQL

Описание к видео SQL Running Total: How To Calculate a Running Total in SQL

📝 Get my free SQL Cheat Sheets: https://www.databasestar.com/get-sql-...
🎓 Learn and become confident in SQL: https://databasestar.mykajabi.com/sql...

Calculating a running total in SQL is something that we need to do sometimes.

A running total is a number that includes all of the previous numbers before it. It can be used to calculate sales so far for a month, or the score so far in a sports match.

You can use the concept of a “window function” in SQL to calculate the running total. This works in major SQL vendors including Oracle, SQL Server, MySQL, and PostgreSQL.

Watch this video to see how to do it: both calculating a running total and a running total for separate groups.

The script used for the sample data is available here: https://dbshostedfiles.s3.us-west-2.a...

Blog post: https://www.databasestar.com/sql-runn...

Timestamps:
00:00 Intro
00:20 What is a running total?
00:40 Sample table
00:57 Select query
02:00 Add the SUM function
03:29 Results
04:03 Grouping and running total
05:32 Summary

Комментарии

Информация по комментариям в разработке