View Full Version : SQL Query Help Needed.?


NoahRyan
03-27-2011, 10:23 PM
The following question has got me stumped and i really need help in trying to figure it out.

Write a SQL querie based on the following database schema about battleships:
Classes (class, type, country, numGuns, bore, displacement)
Ships (name, class, launched)
Battles (name, date)
Outcomes (ship, battle, result)

Q. Find the number of ships launched for only those classes which
had at least one ship in a battle before 1940

Khalid_Afridi
03-27-2011, 11:02 PM
Q. Find the number of ships launched for only those classes which
had at least one ship in a battle before 1940

Did you normalised your tables properly i.e the relationships between the tables has the PK and FK?

What Query u are using to get the result so far?

Your Query should be somthing like this:


SELECT COUNT(*) FROM ships INNER JOIN classes on ship.id=class.shipID
INNER JOIN battle ON ship.id = battle.id
WHERE battles.Date > #1-1-1941#;

NoahRyan
03-27-2011, 11:10 PM
Thank you very much! Helps me a lot.

Khalid_Afridi
03-27-2011, 11:24 PM
Glad to see that you got a help and clue :)