Wednesday 15 April 2015

sql - Return the first iteration of the set of values even if they repeat, -


It's hard to explain with words that I'm trying to accomplish, here's an example. Suppose we have the following table:

  Start Customer Group parentcustomer 1469046 3939 7/1/2010 1311044 1469046 3939 8/1/2010 1311044 1469046 4144 1/1/2011 1460224 1469046 4147 2 / 1/2011 1461557 1469046 3939 11/1/2013 1311044 1469046 3939 12/1/2013 1311044 1469046 3939 1/1/2014 1311044 1469046 3939 2/1/2014 1311044 1469046 3939 3/1/2014 1311044 1469046 3939 4 / 1/2014 1311044 1469046 3939 5/1/2014 1311044 1469046 3939 6/1/2014 1311044 1469046 3939 7/1/2014 1311044 1469046 3939 8/1/2014 1311044 1469046 587 9/1/2014 141274 1469046 587 10/1 / 2014 141274 1469046 587 11/1/2014 141274 1469046 587 12/1/2014 141274 And what I'm trying to do below:  
  Customer Group Initial Generator customer 1469046 3939 7/1/2010 1311044 1469046 4144 1/1/2011 1460224 14690 46 4147 2/1/2011 1461557 1469046 3939 11/1/2013 1311044 1469046 587 9/1/2014 141274  

So, basically, when I only show up for each group Want it started? I have a code that I want, but whoever throws it, the repeating group is 3939. It will only display it when starting from 7/1/2010

Do anyone have any ideas if this is possible and how would I have to do it?

 select  (select *, leg (group, 1,0) over (via order) Before the table) before the table with the group) where the previous group is zero or the previous group & lt; & Gt; Group  

No comments:

Post a Comment