Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)

  • RE: Update Gaps

    with updatebase_cte (MachineID,RecordedDate,Pressure,ind) as (

    select s.MachineID,s.RecordedDate,s.Pressure, 0 as ind

    from yourtable s

    where s.RecordedDate='2012-10-02'

    union all

    select s.MachineID,s.RecordedDate,

    case when s.Pressure = 0 and sc.Pressure <> 0 then sc.Pressure else s.Pressure end as Pressure,

    case when...

  • RE: Solve Problems Using Recursive CTE

    I put the date into the query to make the Island query similar to the last query you posted. That query will only report the first consecutive month for...

  • RE: Solve Problems Using Recursive CTE

    mickyT (12/5/2012)


    So comparing the islands and recursive queries returning similar rows

    ;WITH cte AS (

    SELECT name,

    DATEADD(mm, - ROW_NUMBER() OVER (ORDER BY name, saledate), saledate) dategroup,

    saledate

    FROM #sales

    WHERE quantity > 2...

  • RE: Solve Problems Using Recursive CTE

    There is a particular problem, let's' say, we just want to find out who sold more then 2 each month in at least two consecutive months and when.

    For the above...

  • RE: Solve Problems Using Recursive CTE

    I know Jeff Moden's solution.

    But I assume this way could be faster because there is not sorting for row number.

    At least, it is a different solution.

Viewing 5 posts - 1 through 5 (of 5 total)