DISTINCT with PagedResults
<p>I am sure this will be answered somewhere...</p>

<p><strong>Aim:</strong> Get DISTINCT DOCURL and additional columns</p>

<p><strong>Tried:</strong> 
1. Changing <code>SELECT  * FROM</code> to <code>SELECT  DISTINCT DOCURL FROM</code> which only yields the DOCURL column
2. Adding DISTINCT into the second select (as per example) but again I get all columns and rows. </p>

<p><strong>Notes:</strong> Code is normally built dynamically so I've taken the print... </p>

<pre><code>SELECT  * 
FROM
(
    Select DISTINCT
        isnull(d.DOCURL,'-') As DOCURL,
        isnull(d.ID,'-') As ID, 
        isnull(d.UPRN,'-') As UPRN,
        isnull(d.VFMDISCIPLINE,'-') As VFMDISCIPLINE,
        isnull(d.VFMDISCIPLINEELEMENT,'-') As VFMDISCIPLINEELEMENT ,
        isnull(d.SurveyDate,' ') As SurveyDate,
        isnull(d.WorkOrder,'-') As WorkOrder,
        ROW_NUMBER() OVER (ORDER BY DOCURL) AS ResultSetRowNumber
    From TblData As D 
    WHERE 1 = 1
        AND d.UPRN = '123XYZ' 
        AND (d.VFMDISCIPLINE = '1'   OR  d.VFMDISCIPLINE = '2'  )
) As PagedResults 
WHERE ResultSetRowNumber &gt; 0 And ResultSetRowNumber &lt;= 20
</code></pre>