Assume I have an entity with the following structure:
ID (it would be the GUID of the record, I'll use number in this example for easier read)
Name
Product (lookup to product)
Price List (custom lookup to standard price list)
I now need to build a lookup view in this fashion:
(Sample data) ID Name Product PriceList ----------------------------------- 1 Rec1 P1 PL1 2 Rec1 P1 PL2 3 Rec1 P1 PL3 4 Rec2 P2 PL1 5 Rec2 P2 PL2 (Desired result in lookup view) ID Name ----------------------------------- 1 Rec1 4 Rec2
To explain the requirement in plain english, it is:
In the lookup view I only want one row per Name: Product and Price List don't matter.
Here's what I'd do if I could use straight T-SQL:
;WITH cte AS
(
SELECT ROW_NUMBER()
OVER (PARTITION BY Name ORDER BY Name ASC) AS RowNo, ID, Name
FROM FilteredEntity
)
SELECT ID, Name FROM cte WHERE RowNo = 1
But I can't figure out how to achieve the same result set in a FetchXML query.