Please indicate the source of the original reprint: http://agilestyle.iteye.com/blog/2392433
There is a datasheet DDR
Question: Query the records that appear more than once in T2
SQL Reference
select * from ddr where t2 in ( select t2 from ddr group by t2 having count(t2) > 1 );
There are 2 tables in the database, one Customer, field id, name; one Orders, field id, cid (Customer's ID foreign key), revenue, question: Query the sum of the revenue of each Customer
SQL Reference
select sum(revenue), c.name from orders o LEFT JOIN customer c on o.cid = c.id GROUP BY cid;