根据给定的输入,需要应用条件来获取下表中的最大匹配分数
MATCH_RULES
示例:
if FN=Y&LN=Y&EMAIL=Y&TAX=Y&DOB=Y&MOBILE=Y
then id=1 and match_score=100
if FN=Y&LN=Y&EMAIL=Y&TAX=N&DOB=N&MOBILE=Y
then id=5 and match_score=40
作为给定输入的结果,需要获取高匹配分数满意记录
答案 0 :(得分:1)
你可以在
时使用案例 select case when
(FN='Y' AND LN='Y' AND EMAIL ='Y' AND TAX='Y'
AND DOB = 'Y' AND MOBILE ='Y') THEN 1
when
(FN='Y' AND LN='Y' AND EMAIL ='Y' AND TAX='N'
AND DOB = 'N'AND MOBILE ='Y') THEN 5
end id ,
case when
(FN='Y' AND LN='Y' AND EMAIL ='Y' AND TAX='Y' AND DOB = 'Y' AND MOBILE ='Y') THEN 100
when
(FN='Y' AND LN='Y' AND EMAIL ='Y' AND TAX='N' AND DOB = 'N'AND MOBILE ='Y') THEN 40
end match_Score
from my_table
答案 1 :(得分:0)
在SQL查询中,您可以使用max()
函数来获取列的最大值。在您的情况下,您可以输入类似的内容:
SELECT max(match_score)
FROM ?
WHERE FN = 'Y' and ...