Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Minimum period of a category between category changes

$
0
0

Hi.

I have the following dataset in tempoary memory which shows how a id moves between differenent categories over a period of time. The first view (A) shows what i'm working with. View (B) is my desired result. Below is only an example of one particular ID, my datatset contains thousands of id's.

Please help, this is driving me crazy.

Thanks.

A. CURRENT DATASET

ID              START_PERIOD       CATEGORY

x10001       201205                  5

x10001       201211                  5

x10001       201302                  4

x10001       201303                  3

x10001       201304                  3

x10001       201305                  5 

x10001       201306                  4

B. Desired Result.

ID             MOVE_PERIOD       CATEGORY

x10001       201205                  5

x10001       201302                  4

x10001       201303                  3

x10001       201305                  5

x10001       201306                  4

So basically I want to show the minimum move period, before it can change to the next category and show the same category if it enters it again, but also show that move_period.

Thanks.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>