SELECT -- TOP 1 previd , [Review Link] FROM ( SELECT...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- http://stackoverflow.com/a/1312137/578411

SELECT  -- TOP 1
        -- Uncomment above for SQL Server 2012+
        previd
      , [Review Link]
FROM    (
        SELECT r.id
             , LAG(r.id) OVER (ORDER BY r.id) previd
             , 'site://review/' 
                + case 
                  when reviewtasktypeid=1 then 'suggested-edits'
                  when reviewtasktypeid=2 then 'close'
                  when reviewtasktypeid=3 then 'low-quality-posts'
                  when reviewtasktypeid=4 then 'first-posts'
                  when reviewtasktypeid=5 then 'late-answers'
                  when reviewtasktypeid=6 then 'reopen'
                  when reviewtasktypeid=10 then 'triage'
                  when reviewtasktypeid=11 then 'helper'
                  end
                + '/'
                + cast(r.id as nvarchar) 
                + '|'
                + rt.name as [Review Link]  
        FROM    reviewtasks r
        inner join reviewtasktypes rt on rt.id = r.reviewtasktypeid
        ) q
        WHERE   (id - previd) > 100
ORDER BY
        id
        
        
        select top 10 
        'site://review/' 
        + case 
          when reviewtasktypeid=1 then 'suggested-edits'
          when reviewtasktypeid=2 then 'close'
          when reviewtasktypeid=3 then 'low-quality-posts'
          when reviewtasktypeid=4 then 'first-posts'
          when reviewtasktypeid=5 then 'late-answers'
          when reviewtasktypeid=6 then 'reopen'
          when reviewtasktypeid=10 then 'triage'
          when reviewtasktypeid=11 then 'helper'
          end
        + '/'
        + cast(r.id as nvarchar) 
        + '|'
        + rt.name
               
        from reviewtasks r
        inner join reviewtasktypes rt on rt.id = r.reviewtasktypeid
        order by r.id

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results