例如这样一个表,我想统计email和passwords都不相同的记录的条数
CREATE TABLE IF NOT EXISTS `test_users` (
`email_id` int(11) unsigned NOT NULL auto_increment,
`email` char(100) NOT NULL,
`passwords` ...
分组后,统计记录条数:
SELECT num,count(*) AS counts from test_a GROUP BY num;
查询结果如下:
对num去重后的数量的统计:
SELECT count(t.counts) FROM ( SELECT num,count(*) AS counts ...
一对多写了mapper映射之后
根据条件查条数 可以根据主表的唯一id进行分组
在拿到它的count
select count(0) over(aa.id),,id,name,age from tab1 aa
left join tab2 bb
on aa.id = bb.id
group by aa.id
mybatis...