• Database: tennis
  • table: matches
  • columns: matchno(pk), won, lost ...etc

Problem: Get the match number and the sets won and lost in each match where num of sets won is >= num of sets lost multiplied by 2.

Wrong query:

use tennis;
select matchno, lost * 2 AS spl
from matches 
where won >= spl

What is wrong in this query? How can it be modified to get the right output?

Correct query:

select matchno, won, lost
from matches
where won >= lost * 2
有帮助吗?

解决方案

SELECT matchno, lost * 2 AS spl
FROM matches
WHERE won >= (lost * 2)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top