我有一个大型查询,可以根据搜索拉回联系人。这是查询的简化示例。(表和字段名称已更改以保护无辜。)
SELECT DISTINCT TOP 20 DB1.FieldID, DB1.Field1, DB.Field2, DB.Field3,
DB2.Field88, DB3.Field77
FROM tblLamp DB1
LEFT JOIN tblSand DB2 ON DB2.FieldID = DB1.FieldID
LEFT JOIN tblLime DB3 ON DB3.FieldID = DB1.FieldID
WHERE (Field1 LIKE 'hotwet%' ESCAPE '!' OR Field2 LIKE 'maarten%' ESCAPE '!')
AND DB2.Field99 != '1111-2222-3333-4444'
AND (DB1.CreatorID IN (...) OR DB1.OwnerID IN (...) OR DB1.FieldID IN (...))
ORDER BY DB1.Field1 ASC, DB1.Field2 ASC
我在网上找到了很多使用 ROW_NUMBER() 的示例,但我无法让它与这个查询一起工作。有任何想法吗?