question

aqtab avatar image
aqtab asked

SQL View to return data from two tables partially

I have two tables Budget and Actual.

Both tables have 3 Columns each.

I want to create a view for returning data combining two table rows based on a period filter.

I should be able to filter from the view. For example, if I filter the view with the column PerNbr 202205, then the view should return the actual table's data till 202204 and the budget table's data from 202205.

Actual Data

Account PerNbr Amount

10234 202201 1000

10234 202202 1000

10234 202203 1000

10234 202204 1000

10234 202205 1000

10234 202206 1000

10234 202207 1000

10234 202208 1000

10234 202209 1000

10234 202210 1000

10234 202211 1000

10234 202212 1000

Budget Data

Account PerNbr Amount

10234 202201 1500

10234 202202 1500

10234 202203 1500

10234 202204 1500

10234 202205 1500

10234 202206 1500

10234 202207 1500

10234 202208 1500

10234 202209 1500

10234 202210 1500

10234 202211 1500

10234 202212 1500

Expecting Result

Account PerNbr Amount

10234 202201 1000

10234 202202 1000

10234 202203 1000

10234 202204 1000

10234 202205 1500

10234 202206 1500

10234 202207 1500

10234 202208 1500

10234 202209 1500

10234 202210 1500

10234 202211 1500

10234 202212 1500



viewssqlquery
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.