Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. --CARS table
  2. car_id (PK), car_model, car_miles
  3.  
  4. --TRIPS table
  5. trip_id (PK), trip_destination, trip_date, trip_miles, car_id (FK)
  6.  
  7. --CARS table
  8. C01, FORD Edge, 100,000
  9. C02, CHEVY Malibu, 89,200
  10. C03, DODGE Avenger, 75,000
  11.  
  12. --TRIPS table
  13. T01, NYC, 10-jul-2019, 20, C01
  14. T02, Brooklyn, 12-jul-2019, 15, C01
  15. T03, NYC, 09-jul-2019,25, C03
  16.  
  17. Car_MODEL | TOTAL TRIPS
  18. --------------|------------
  19. FORD EDGE | 2
  20. DODGE AVENGER | 1
  21.  
  22. --SQL Query
  23. SELECT SUM(trip_id), car.car_model
  24. FROM trips
  25. LEFT LEFT JOIN car ON trips.car_id = car.car_id
  26. WHERE trips.car_id = car.car_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement