with supp as (
Select
ROW_NUMBER() over (partition by WVTSupporter.id order by WVTSupporter.id desc ) rn,
convert(nvarchar(100),WVTProductHeader.code) ProductCode,
WVTSupporter.id SupporterID,
From dbo.WVTContribution
Inner Join dbo.WVTSupporter
ON WVTContribution.p_mySupporterExtra = WVTSupporter.myExtraInfo
WHERE
WVTProductHeader.code = '16FAMGRP'
),
supp1 as (
Select
ROW_NUMBER() over (partition by WVTSupporter.id order by WVTSupporter.id desc ) rn,
convert(nvarchar(100),WVTProductHeader.code) ProductCode,
WVTSupporter.id SupporterID,
From dbo.WVTContribution
Inner Join dbo.WVTSupporter
ON WVTContribution.p_mySupporterExtra = WVTSupporter.myExtraInfo
WHERE
WVTProductHeader.code = '16FAMGRP'
)
SELECT * from supp
INNER JOING supp1 ON supp=supp1
where Rn = 1
with supp as (
Select
ROW_NUMBER() over (partition by WVTSupporter.id order by WVTSupporter.id desc ) rn,
convert(nvarchar(100),WVTProductHeader.code) ProductCode,
WVTSupporter.id SupporterID,
From dbo.WVTContribution
Inner Join dbo.WVTSupporter
ON WVTContribution.p_mySupporterExtra = WVTSupporter.myExtraInfo
WHERE
WVTProductHeader.code = '16FAMGRP'
)
SELECT * from supp where Rn = 1