目的:
需要将多个表合并查询,
使用:
SQL 中的join进行合并!
格式就是使用 join 不断的链接就好了。
要3个表就使用3个,
要4个就使用4个,
select * from table1
inner join
table2
on table1.a=table2.a
…
inner join
tableN
on table1.a=tableN.a
select *
from
(select to_char(record_t, 'YYYY-MM-DD HH24 ' ) as d , avg (ct_loop1) as loop1_CT from public.loop1_daily
group by d order by d DESC LIMIT 8) as t1
inner JOIN
(select to_char(record_t, 'YYYY-MM-DD HH24 ' ) as d , avg (ct_loop2) as loop2_CT from public.loop2_daily
group by d order by d DESC LIMIT 8) as t2
ON t1.d=t2.d
inner JOIN
(select to_char(record_t, 'YYYY-MM-DD HH24 ' ) as d , avg (ct_loop3) as avge_CT3 from public.loop3_daily
group by d order by d DESC LIMIT 8) as t3
ON t1.d=t3.d