。。
select
sum(XSSL*DJ),MONTH(XSSJ)
from
tb_XS
group
by
(year(xssj)-MONTH(XSSJ))
是这个意思吗?
一共加了三条数据
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条)