SQLTeam.com | Weblogs | Forums

Wrong query output

Exercise: 70
Get the battles in which at least three ships from the same country took part.

The database consists of the following relations:
Classes(class, type, country, numGuns, bore, displacement)
Ships(name, class, launched)
Battles(name, date)
Outcomes(ship, battle, result)

Notes: 4) A ship found in the Outcomes table but not in the Ships table is still considered in the database. This is true even if it is sunk.

DDL? sample Data?

SELECT DISTINCT O.battle
FROM Outcomes O
INNER JOIN Ships S ON S.name = O.ship
INNER JOIN Classes C ON C.class = S.class
GROUP BY O.battle, C.country
HAVING COUNT(*) >= 3

@mike01 hello mike , im very sorry for not being able to find the ddl because the website doesnt give that to users we just have to built the query with what i told u , thanks for ur supporting

@ScottPletcher thanks for helping me everytime i ask here , thanks thanks thanks u made me understand this i was stucked on the having count , thank u :slight_smile:

You're very welcome!