Skip to content
Advertisement

How to get totals from another table

I have table 1 of Cars and table 2 Trips. Below are the two tables fields

Samle Data

I would like to get the car model with a total number of trips it took like this:

I tried this query, but I get %s: invalid identifier error

Advertisement

Answer

It doesn’t make sense to aggregate on a field from the left side of a join. It also doesn’t make sense to use sum() on an id. And, your attempted query has other syntax errors as well.

I assume you intend:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement