select * from B as bwhere b.BillNum in (select b.BillNum from Bgroup by b.BillNum having count(1) > 1) -------------------------------------- id(int) cost(int) des Autoid(id) -------------------------------------- 1 10 aaaa 1 1 15 bbbb 2 1 20 cccc 3 2 80 aaaa 4 2 100 bbbb 5 2 60 dddd 6 3 500 dddd 7 -------------------------------------- 取每一类id中cost最大的纪录
在上一节中我们们安装了mysql以及navicat,并掌握了如何创建库、创建表、修改表和插入、删除以及更新 数据 。这一节我们将继续学习SQL的简单 查询 语句。一、基本的 查询 语句1、select子句和from子句select <列名1>,<列名2>... from <表名>; select * from <表名>;(查看全部列) 查询 语句的运行过程如图2、...
select count(*) as U from (select count(*) as c from test.user group by b)as t where t.c >=2; select count(*) from (select count(*) from test.`user` group by b having count(*)>=2) as t ;