Home > database >  For a sum aggregate function multi-table query
For a sum aggregate function multi-table query

Time:11-20

There are two tables (came sales TAB) and B (store brand sales summary), structure is shown in figure:




To achieve the effect of is, A, B two table, megabite name=famous brand shoe shoe kind the three columns and results of joining together into A table,

Total amount to be, the number of orders to be pen result: 11407865.2, 4938 this is the
Summary of transaction and the result should be: 100
Now shows 9500? Excuse me, where is wrong?




 

SELECT sum (came sales statistics. The total amount to be) AS AA, the sum (be sales statistics. Order came pen) AS BB, sum (store brand sales summary. Collect transaction amount) AS CC
The FROM to be sales statistics INNER JOIN shops brand sales summary ON came sales statistics. Megabite=store brand sales summary. The summary megabite
WHERE came the sales statistics. Megabite='famous brand shoe shoe kind And store brand sales summary. The summary megabite=' famous brand shoe shoe kind;

  • Related