2:SELECT SUM(总藏书量)/count(总藏书量),SUM(管内剩余)/count(管内剩余) FROM `藏书信息` GROUP BY 入库时间
一共加了三条数据
insert into pl_org_region(parent_id,region_sn,region_name,comments) values (0,'001','北京大区','无')insert into pl_org_region(parent_id,region_sn,region_name,comments) values (0,'002','西南大区','无')
insert into pl_store (store_sn,region_id,region_name) values ('P001',6,'北京大区')
查询语句改成:
SELECTp.region_id,
COUNT(p.region_id) AS cnt,
r.*
FROM
pl_org_region r
LEFT JOIN pl_store p ON r.region_id = p.region_id
GROUP BY
p.region_id
查询结果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)