擅长:python、mysql、java
<p>哦,您需要的是<code>null</code>值最少的行。我建议:</p>
<pre><code>select t.*
from (select t.*,
dense_rank() over (order by (case when firstname is null then 1 else 0 end) +
(case when middlename is null then 1 else 0 end) +
(case when lastname is null then 1 else 0 end)
) as seqnum
from t
) t
where seqnum = 1;
</code></pre>
<p>这是ANSI标准SQL。你知道吗</p>