Fordraiders
asked on
for any repeated "contract_number" 1 row return where the "Qualification Percent" number is the highest.
In relation to previous question.
https://www.experts-exchange.com/questions/29134757/need-a-select-case-statement-that-will-add-2-fields-after-evaluating-a-calculation-in-the-case-statement.html?headerLink=workspace_answered_questions
Instead of returning more than 1 record for THE field(contract_number) that has more than 1 to return.
I need only to return 1 ROW.
current return:
desired return:
So i need: for any repeated "contract_number" and a has no "out of date" language in "Qualification Percent"
1 row return where the "Qualification Percent" number is the highest.
Thanks
fordraiders
https://www.experts-exchange.com/questions/29134757/need-a-select-case-statement-that-will-add-2-fields-after-evaluating-a-calculation-in-the-case-statement.html?headerLink=workspace_answered_questions
SELECT [contract_number]
,[From_Dollar]
,[To_Dollar]
,[Base_Discount_Percent]
,[Start_Date]
,[End_Date]
,[Sum_Of_Sales_Current]
,CASE
WHEN ISNULL(base_Discount_Percent,0) = '' THEN 'no data'
WHEN ISNULL(Sum_Of_Sales_Current, 0) < From_Dollar THEN 'BELOW RANGE'
WHEN ISNULL(Sum_Of_Sales_Current, 0) > To_Dollar THEN 'ABOVE RANGE'
ELSE 'BETWEEN RANGE'
END AS RANGE_SCORE,
CASE WHEN Base_Discount_Percent IS NULL THEN ''--'NONE STATED'
WHEN End_Date <= CAST(GETDATE() AS DATE) THEN 'OUT OF DATE'
WHEN ISNULL(Sum_Of_Sales_Current, 0) < From_Dollar THEN '0'
ELSE Convert(nvarchar(50),Base_Discount_Percent)
END AS QUALIFICATION_PERCENT
FROM [program].[dbo].[TIER_CAT]
Instead of returning more than 1 record for THE field(contract_number) that has more than 1 to return.
I need only to return 1 ROW.
current return:
desired return:
So i need: for any repeated "contract_number" and a has no "out of date" language in "Qualification Percent"
1 row return where the "Qualification Percent" number is the highest.
Thanks
fordraiders
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER