基于列优先级的 MSSQL 查询
MSSQL query based on column priority
![在此处输入图片描述][1]
我的 MSSQL table 具有这些属性 - id1、id2、isVerified、isRejected、score1、score2、score3。我想显示 top1 值,其中 isveried == 1,isRejected==0。在那之后,我的首要任务是 score1。如果 score1 与任何其他值关联,则第二优先级为 score2,如果 score2 关联,则第三优先级为 score3。数字越大,优先级越高。查询是什么?请帮忙
我怀疑你想要:
select top (1) *
from mytable
where isverified = 1 and isrejected = 0
order by score1 desc, score2 desc, score3 desc
查询筛选已验证的行和 non-rejected 行。然后,我们保留最高 score1
的行;如果有联系,我们比较 score2
,然后 score3
.
![在此处输入图片描述][1]
我的 MSSQL table 具有这些属性 - id1、id2、isVerified、isRejected、score1、score2、score3。我想显示 top1 值,其中 isveried == 1,isRejected==0。在那之后,我的首要任务是 score1。如果 score1 与任何其他值关联,则第二优先级为 score2,如果 score2 关联,则第三优先级为 score3。数字越大,优先级越高。查询是什么?请帮忙
我怀疑你想要:
select top (1) *
from mytable
where isverified = 1 and isrejected = 0
order by score1 desc, score2 desc, score3 desc
查询筛选已验证的行和 non-rejected 行。然后,我们保留最高 score1
的行;如果有联系,我们比较 score2
,然后 score3
.