你看这样行吗?
CREATE TEMPORARY TABLE tmp
insert into tmp select a,sum(b) as c from table1 where e=tj1 group by a
select * from tmp where c=tj2
DROP TABLE tmp
CREATE TEMPORARY TABLE tmp
insert into tmp select a,sum(b) as c from table1 where e=tj1 group by a
select * from tmp where c=tj2
DROP TABLE tmp
select a ,sum(b) as c from table1 where e=tj1 and c=tj2 order by c=tj3 group by a
你可以用它实现!
这是个模式,套用就可以了。
select table1.* from table1 left join table2 on table1.column1 = table2.column2 where table2.column2 is null