SELECT
ClientSet.*
FROM ClientSet LEFT JOIN (SELECT
*
,ROW_NUMBER() OVER (PARTITION BY Client_Id ORDER BY Priority ) as rn
FROM OrderSet) on OrderSet.Client_Id=ClientSet .ID
WHERE OrderSet.rn=1 OR OrderSet.rn IS NULL