-4

Sorry, but im not sure how to properly format on here but i have 2 tables where i have to answer the question in the title. I have no idea how too but it's homework. I keep seeing things on joins but that is confusing.

DEPOT TABLE
DEPOT DEPOT_NAME ADDRESS
1008 user1 address1

DRIVER TABLE

DRIVER SALARY DEPOT#(FORIEGN KEY)
driver# 100.00 1008
4
  • Hi, and welcome to dba.se! We weren't born knowing SQL, so here goes. Go to dbfiddle.uk and create your tables, two depots. one with two drivers, one with three drivers. Give them different salaries. Then run SELECT de.*, dr.* FROM depot de, driver dr;. What is your resultset? Jun 18 at 7:00
  • i have no idea what im doing on that website honestly, also this is due midnight tonight, is there any faster way i can be assisted? My teacher taught us the basics of SQL and gave us a lab with a set of stuff she didn't teach so some terms that u may use I may not understand because I am not familiar Jun 18 at 17:22
  • Do what I said above. You will obtain 6 records when you require 2 - the SUM of bus drivers' salaries by depot. The way you reduce the number of records is by JOINing them on the fields where they overlap... so, you have depot (obviously enough) in the depot table and in the driver table. You JOIN depot to driver using the depot_no. and that will reduce the number of records returned - do this step first - then you can get some hints on the final SUMming step! Just doing people's homework is considered unhelpful here - at least give what I have suggested a go! Jun 18 at 17:35
  • 2
    Show that you have made some effort! Jun 18 at 17:58

1 Answer 1

-1

I'm just too generous tonight, HYG:

SELECT a.DEPOT_NAME,
       SUM(b.SALARY) TOTAL_SALARY
FROM DEPOT a
INNER JOIN DRIVER b ON a.DEPOT# = b.DEPOT#
GROUP BY a.DEPOT_NAME

Not the answer you're looking for? Browse other questions tagged or ask your own question.