How to get Sum from two tables?

后端 未结 1 892
清歌不尽
清歌不尽 2021-01-29 11:57

i have two tables first one name is \"sales\" and second one name is \"items\" in both tables have same columns \"code\" and \" qtd \"; i want write MYSQL query witch i need sum

相关标签:
1条回答
  • 2021-01-29 12:11

    Try this:

    Select code, sum(qtd) 
    from (
    select code, qtd from sales
    union all
    select code, qtd from items) as innerTable
    group by code
    
    0 讨论(0)
提交回复
热议问题