Итак, у меня есть 4 разные таблицы, и я хочу поместить их в одну таблицу с одним из столбцов из таблиц, и сколько раз конкретное значение появляется в этом столбце. Все столбцы являются строками.
Например:
table A
col1
20190204
20190204
20190204
20190205
20190205
20190205
Table B
col1
20200204
20200204
20200204
20200204
20200205
20200205
20200205
TableC
col1
20210204
20210204
20210204
20210204
20210205
20210205
20210205
TableD
col1
20220204
20220204
20220204
20220204
20220205
20220205
20220205
TableE -- All the 4 tables will go into here
TableE is empty and needs to be populated with the dates from the other tables and the number of times they occur in those tables. For example:
col1(tablea) col2 col3(tbaleb) col4 col5(tablec) col6
20190204 4 20200204 4 20210204 4
20190205 3 20200205 3 20210205 3
col7(tabled) col8
20220205 3
20220205 4
etc...
Я новичок в hue, поэтому я попробовал что-то вроде этого:
insert overwrite into tablee (
tablee.tablea.date, tablee.tablea.datecount,
tablee.tablebdate, tablee.tableb.datecount,
tablee.tablecdate, tablee.tablec.datecount,
tablee.tableddate, tablee.tablea.datedcount,
select tablea.date, count(tablea.date),
tableb.date, count(tableb.date),
tablec.date, count(tablec.date),
tabled.date, count(tabled.date)
)
from tablea, tableb, tablec, tabled
left join tablee on (tablea.date=tablee.date)
left join tablee on (tableb.date=tablee.date)
left join tablee on (tablec.date=tablee.date)
left join tablee on (tabled.date=tablee.date);
Но я не могу заставить его работать правильно. У кого-нибудь есть советы?