Skip to content

Tag: tsql

Getting previous month data not working in sql server

I am trying to get the previous month data according to the datetime in the column dynamically for example I have data like this Now I want the records previous than Opendt. The problem is that I am getting the record after Opendt but I am getting empty when I am getting the record before 1 month or 2 month

Merge lines over timespan in SCD2 table

I’m having the following table sourced from a SCD2 table. From this source table, I have selected only a few columns, which reults in several lines looking exactly similar. I want to remove the unnecessary lines, those that contain the same data, and have the ValidFrom column showing the first value and…