select year,month,sum(gmv) as gmv,sum(count) as count from 2018_order_book GROUP BY year,month union SELECT year,month,sum(gmv) as gmv,sum(count) as count from 2019_order_book GROUP BY year,month union SELECT year,month,sum(gmv) as gmv,sum(count) as count from 2020_order_book GROUP BY year,month order by year,month
select count(1) from (select year,month,sum(gmv) as gmv,sum(count) as count from 2018_order_book GROUP BY year,month union SELECT year,month,sum(gmv) as gmv,sum(count) as count from 2019_order_book GROUP BY year,month union SELECT year,month,sum(gmv) as gmv,sum(count) as count from 2020_order_book GROUP BY year,month order by year,month) t