math operations between queries Impala SQL
Solution 1:
You can join them on a dummy column and then divide the result sets.
SELECT cnt1.cnt1/cnt2.cnt2
FROM
(SELECT count(DISTINCT t1.ids) cnt1, 'dummy' dum
FROM table1 t1
WHERE YEAR (t1.insertdate)=2020) cnt1
JOIN
(SELECT count(DISTINCT t2.ids) cnt2, 'dummy' dum
FROM table2 t2
WHERE YEAR (t2.insertdate)=2019) cnt2
ON cnt1.dum= cnt2.dum -- dummy column