mysql - How do I join these two SQL queries? -


i'm using mysql , mssql , i'm trying join these 2 queries together.

query 1

(select rep.rep_num, rep.first_name, rep.last_name rep, customer) 

query 2

(select customer.rep_num, sum(customer.balance) rep_balance customer group customer.rep_num)  

i've seen can treat these 2 tables , join them i'm having trouble getting work. way trying join them i'd aggregate errors trying select rep first , last name while using balance sum.

thanks in advance!

select r.rep_num, r.first_name, r.last_name rep r inner join (select c.rep_num, sum(c.balance) rep_balance customer c group c.rep_num) t on r.rep_num = t.rep_num 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -