mysql - SQL left join with SUM -


i need join 1 table another, each type of group in left table got sum of value types in second table, group_type = 4. tried following:

select * orbiting_group_types ogt left join (select sum(val)  report_orbiting_vals  rov  order type  rov.orbiting_group_type_id = 4) on ogt.id = rov.orbiting_group_type_id 

however throw me error -

 syntax error @ or near "where" line 8:  rov.orbiting_group_type_id = 4) 

what did miss?

try this:

select * orbiting_group_types ogt left join (select sum(val) report_orbiting_vals  subrov subrov.orbiting_group_type_id = 4 //order type ) rov on ogt.id = rov.orbiting_group_type_id 

1) should name subqueries reference them. can't make reference outside of subquery inside.

2) type doesn't sound column name

3) order goes after where, always.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -