Join three tables in SQL Server 2008 -


i have 3 tables.

a

id   name   ---  ----    1    abc    2    asd   3    qwe 

b

id    income   ---   ------   1      2   2      3   1      4 

c

name   total   ----  ----     abc    8   asd    20 

i want join 3 tables sql query produce output

id income total   --------------- 1    6       8   2    3      20 

could me?

you try this:

select      t1.id, sum(t2.income) income, sum(t3.total) total      table1 t1  join      table2 t2 on t1.id = t2.id join      table3 t3 on t3.name = t1.name group      t1.id order      t1.id 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -