March 2, 2018 at 12:29 pm
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
Viewing 0 posts
You must be logged in to reply to this topic. Login to reply