Back to Browse

Combing two SQL Server tables together, and creating a Running Total

2.9K views
Jul 7, 2022
11:56

I want to combine two tables together, and then create a running total. But how can I do this? My SQL Server Udemy courses are: 70-461, 70-761 Querying Microsoft SQL Server with T-SQL: https://rebrand.ly/querying-microsoft-sql-server 98-364: Database Fundamentals (Microsoft SQL Server): https://rebrand.ly/database-fundamentals 70-462 SQL Server Database Administration (DBA): https://rebrand.ly/sql-server-dba Microsoft SQL Server Reporting Services (SSRS): https://rebrand.ly/sql-server-ssrs SQL Server Integration Services (SSIS): https://rebrand.ly/sql-server-ssis SQL Server Analysis Services (SSAS): https://rebrand.ly/sql-server-ssas-mdx Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpivot-ssas-tabular-dax ---- If you want to do this as a Practice Activity, then please used this code to start with. DROP TABLE IF EXISTS Incoming; DROP TABLE IF EXISTS Outgoing; CREATE TABLE Incoming (DateTransaction date, Amount money); CREATE TABLE Outgoing (DateTransaction date, Amount money); INSERT Incoming VALUES ('2023-01-01', 50), ('2023-02-01', 100) INSERT Outgoing VALUES ('2023-02-01', 30), ('2023-03-01', 25); SELECT * FROM Incoming SELECT * FROM Outgoing; In this video, we'll create two tables, an Incoming and Outgoing table. We'll combine them using a UNION statement (you could use a UNION ALL instead), and then create a Running Total using a CTE and a Window function using OVER.

Download

0 formats

No download links available.

Combing two SQL Server tables together, and creating a Running Total | NatokHD