use test;
select * from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts;
select * from a1 a left join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1;
select a.* from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts;
select b.* from a1 a left join (select __const__ as ts, f, g, 'a' from b1) b on a.ts = b.ts;
select b.* from a1 a left join (select __const__ as ts1, f, g, 'a' from b1) b on a.ts = b.ts1;
select a.*, b.ts from a1 a left join (select __const__ as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1;
select b.c from a1 a left join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts;
select b.ts from a1 a left join (select __const__ as ts, f, g, 'a' c from b1) b on a.ts = b.ts;
select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts;
select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts;
select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts;
select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts;
select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;
select b.ts1,a.ts from a1 a left join (select __const__ as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts;
select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;
select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts;
select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts;
select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts;
select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts;
select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts;
select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts;
select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts;
select * from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1;
select a.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1;
select b.* from a1 a left join (select __const__ as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1;
select b.c from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
select b.ts from a1 a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from a1) a left join (select __const__ as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1;
select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2;
select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by ta.val;
select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=__const__ where tb.ts=__const__ order by tb.val;
select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta left join (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__;
select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2;

select a.* from (select __const__ as ts, f, g, 'a' from b1) b left join a1 a  on a.ts = b.ts;
select b.c from (select __const__ as ts, f, g, 'a' c from b1) b left join a1 a  on a.ts = b.ts;
select b.g from (select __const__ as ts, f, g, 'a' c from b1) b left join a1 a  on a.ts = b.ts;
select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on b.ts1 = a.ts;
select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a  on b.ts1 = a.ts;
select b.c from (select __const__ as ts1, f, g, 'a' c from b1) b left join a1 a  on b.ts1 = a.ts;
select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on a.ts = b.ts;
select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a  on a.ts = b.ts;
select b.ts,a.* from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a  on a.ts = b.ts;
select a.*,b.ts from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on b.ts1 = a.ts and a.ts = b.ts;
select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on b.ts1 = a.ts and a.ts = b.ts;
select b.ts,b.f from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on b.ts1 = a.ts and a.ts = b.ts;
select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a  on b.ts1 = a.ts and a.ts = b.ts;
select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a  on b.ts1 = a.ts and a.ts = b.ts;
select b.ts, a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on b.ts = a.ts and a.ts = b.ts1;
select a.* from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on b.ts = a.ts and a.ts = b.ts1;
select b.g from (select __const__ as ts1, ts, f, g, 'a' from b1) b left join a1 a  on b.ts = a.ts and a.ts = b.ts1;
select b.c from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a  on b.ts = a.ts and a.ts = b.ts1;
select b.ts from (select __const__ as ts1, ts, f, g, 'a' c from b1) b left join a1 a  on b.ts = a.ts and a.ts = b.ts1;
select tb.val,tb.tg1,ta.* from (select __const__ ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1;
select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2;
select tb.val,tb.tg2,ta.* from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;
select * from (select __const__ ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>__const__ where tb.ts>__const__;


