如下表结构跟sql
想查询出 如下形式:
区域名称 省个数 市个数
一级区域 1 2
二级区域 1 1
一个区域下会有多个省份 不同市区
表sql结构与数据
-- ----------------------------
-- Table structure for data
-- ----------------------------
DROP TABLE IF EXISTS "public"."data";
CREATE TABLE "public"."data" (
"id" int4 NOT NULL,
"quyu" varchar(255) COLLATE "pg_catalog"."default",
"province" varchar(255) COLLATE "pg_catalog"."default",
"county" varchar(255) COLLATE "pg_catalog"."default"
)
;
COMMENT ON COLUMN "public"."data"."quyu" IS '区域名称';
COMMENT ON COLUMN "public"."data"."province" IS '省名称';
COMMENT ON COLUMN "public"."data"."county" IS '县名称';
-- ----------------------------
-- Records of data
-- ----------------------------
INSERT INTO "public"."data" VALUES (1, '一级区域', '100000', '100001');
INSERT INTO "public"."data" VALUES (2, '一级区域', '100000', '100002');
INSERT INTO "public"."data" VALUES (3, '二级区域', '110000', '110001');
-- ----------------------------
-- Primary Key structure for table data
-- ----------------------------
ALTER TABLE "public"."data" ADD CONSTRAINT "data_pkey" PRIMARY KEY ("id");