SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Finding difference in Data Warehouse Temporal tables


Finding difference in Data Warehouse Temporal tables

Author
Message
Stephen crocker
Stephen crocker
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2112 Visits: 466
I have 2 tables that join to create a contract and the items that affect the contract like price quantity, etc.
I'm trying to find the best way to put this together. What the customer wants is all of the stuff for the Current Month and the latest record from the previous month.
When I created the Query for the Current month I have in the where clause
where c.SysStart <= Getdate() AND C.SysEnd > Getdate()
and D.SysStart <=Getdate() and D.SysEnd
----Where C is the Contract and D is the Details on the contract

Example: Want everything that's Greater than 3/1/2018 and Less Than or Equal to 2/28/2018. Where one of 6 columns in that table change. The issue is that their is columns in the contract and Columns in the Details that can change
I've tried Max, Min and with the multiple columns that can change it's becoming a pain in the butt to say the least. I'm getting lost.

Would like some advice on what approach to take. This is a Temporal Warehouse not a standard Database and things change all the time.

Here is an example of what I want the output to be: ****CM = Current Month PM = Previous Month
Contract # CM_Price PM Price Price Diff CM_Freight , PM_Freight Diff Freight
1234 1.0000 2.00000 1.0000 0.1000 0.1000 0

As kind of an example. Can supply data if needed just need help on an approach. It's different querying a Temporal Table
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search