数据库复杂SQL语句

CREATE TABLE `eb_location` (

  `EBLC_ID` BIGINT(20) NOT NULL AUTO_INCREMENT,

  `EBLC_CODE` VARCHAR(32) DEFAULT NULL COMMENT '地点代码,对于港口则维护港口代码',

  `EBLC_NAME_SHORT` VARCHAR(50) DEFAULT NULL COMMENT '地点简称',

  `EBLC_NAME_CN` VARCHAR(128) DEFAULT NULL COMMENT '地点中文名称',

  `EBLC_NAME_EN` VARCHAR(64) DEFAULT NULL COMMENT '地点英文名称',

  `EBLC_COUNTRY_CODE` VARCHAR(32) DEFAULT NULL COMMENT '国家代码,ES_PLACE表',

  `EBLC_COUNTRY_NAME` VARCHAR(64) DEFAULT NULL COMMENT '国家名称,ES_PLACE表,冗余名称字段',

  `EBLC_PROVINCE_NAME` VARCHAR(64) DEFAULT NULL COMMENT '省名称,ES_PLACE表,冗余名称字段',

  `EBLC_EBRG_NAME` VARCHAR(64) DEFAULT NULL COMMENT '区域名称,EB_REGION表,冗余名称字段',

  `EBLC_CITY_NAME` VARCHAR(64) DEFAULT NULL COMMENT '市名称,ES_PLACE表,冗余名称字段',

  `EBLC_FLOWS` VARCHAR(100) DEFAULT NULL COMMENT '地点流向',

  `EBLC_LONGITUDE` VARCHAR(20) DEFAULT NULL COMMENT '经度',

  `EBLC_LATITUDE` VARCHAR(20) DEFAULT NULL COMMENT '纬度',

  `EBLC_ADDRESS` TEXT COMMENT '地点详细地址',

  `REC_VER` INT(11) NOT NULL COMMENT '版本号',

  `REC_STATUS` TINYINT(4) NOT NULL COMMENT '地点状态',

  `CREATOR` VARCHAR(64) NOT NULL COMMENT '创建人',

  `CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',

  `MODIFIER` VARCHAR(64) NOT NULL COMMENT '修改人',

  `MODIFY_TIME` DATETIME NOT NULL COMMENT '修改时间',

  `ORG_ID` VARCHAR(32) DEFAULT NULL COMMENT '所属分公司',

  `EBLC_ZIP` VARCHAR(10) DEFAULT NULL COMMENT '邮编',

  `EBLC_PROVINCE_CODE` VARCHAR(32) DEFAULT NULL COMMENT '省代码,ES_PLACE表',

  `EBLC_EBRG_CODE` VARCHAR(32) DEFAULT NULL COMMENT '区域代码,EB_REGION表',

  `EBLC_CITY_CODE` VARCHAR(128) DEFAULT NULL COMMENT '市代码,ES_PLACE表',

  `EBLC_COUNTY_CODE` VARCHAR(32) DEFAULT NULL COMMENT '县代码',

  `EBLC_COUNTY_NAME` VARCHAR(64) DEFAULT NULL COMMENT '县名称',

  `EBLC_ATTRIBUTIVE` VARCHAR(32) DEFAULT NULL COMMENT '地点所属',

  `EBLC_ACTION_TYPE` VARCHAR(32) DEFAULT NULL COMMENT '作用类型',

  `EBLC_COMPANY_CODE` VARCHAR(32) DEFAULT NULL COMMENT '公司编码',

  `EBLC_COMPANY_NAME` VARCHAR(128) DEFAULT NULL COMMENT '公司名称',

  `EBLC_STATION_CODE` VARCHAR(32) DEFAULT NULL COMMENT '基地代码',

  `EBLC_HEIGHT` DECIMAL(18,8) DEFAULT NULL COMMENT '高度限制',

  `EBLC_STATION_NAME` VARCHAR(64) DEFAULT NULL COMMENT '基地名称',

  `EBLC_IS_TEMPORARY` VARCHAR(2) DEFAULT NULL COMMENT '是否临时',

  `EBLC_NEW_ADDRESS` TEXT COMMENT '详细地址',

  `EBLC_LIMIT_VEHICLE_CAPACITY` TEXT COMMENT '限制车型能力',

  `EBLC_FIRST_TIME` INT(11) DEFAULT NULL COMMENT '要求最早收货时间hh:mm',

  `EBLC_LATEST_TIME` INT(11) DEFAULT NULL COMMENT '要求最晚收货时间hh:mm',

  `EBLC_ARRIVAL_DAY` DECIMAL(12,2) DEFAULT NULL COMMENT '时效',

  `EBLC_VALID_RADIUS` VARCHAR(8) DEFAULT NULL COMMENT '有效半径',

  `EBLC_AREA_CODE` VARCHAR(32) DEFAULT NULL COMMENT '区域编码',

  `EBLC_AREA_NAME` VARCHAR(64) DEFAULT NULL COMMENT '区域名称',

  `EBLC_IS_UPLOAD` VARCHAR(32) DEFAULT NULL COMMENT '是否上传(是Y,否N)',

  PRIMARY KEY (`EBLC_ID`) USING BTREE,

  KEY `IDX_EBLC_STATION_CODE` (`EBLC_CODE`,`ORG_ID`,`EBLC_STATION_CODE`) USING BTREE,

  KEY `INX_EL_EEO` (`EBLC_CODE`,`EBLC_ACTION_TYPE`,`ORG_ID`) USING BTREE

) ENGINE=INNODB AUTO_INCREMENT=1117040 DEFAULT CHARSET=utf8 COMMENT='地点' shardkey=noshardkey_allset;

CREATE TABLE `es_company` (

  `ESCO_ID` DECIMAL(12,0) NOT NULL COMMENT '公司表主键',

  `ESCO_PARENT_ESCO_ID` DECIMAL(12,0) NOT NULL COMMENT '上级公司ID',

  `ESCO_EBPL_CITY_ID` DECIMAL(12,0) DEFAULT NULL COMMENT '所在城市',

  `ESCO_COMPANY_NO` VARCHAR(32) DEFAULT NULL COMMENT '公司编码',

  `ESCO_COMPANY_NAME_CN` TEXT COMMENT '公司名称',

  `ESCO_COMPANY_NAME_EN` TEXT COMMENT '公司英文名称',

  `ESCO_SEND_CODE` VARCHAR(64) DEFAULT NULL COMMENT '发送代码,为EDI功能预留的字段',

  `ESCO_ADDRESS_CN` TEXT COMMENT '公司地址',

  `ESCO_ADDRESS_EN` TEXT COMMENT '公司英文地址',

  `ESCO_POSTALCODE` VARCHAR(32) DEFAULT NULL COMMENT '邮编',

  `ESCO_FAX` VARCHAR(32) DEFAULT NULL COMMENT '传真号',

  `ESCO_URL` TEXT COMMENT '公司URL',

  `ESCO_BUSINESS_NO` VARCHAR(32) DEFAULT NULL COMMENT '工商号',

  `ESCO_PHONE` VARCHAR(32) DEFAULT NULL COMMENT '电话号码',

  `ESCO_TAX_NO` VARCHAR(32) DEFAULT NULL COMMENT '税务号',

  `ESCO_CURRENCY` VARCHAR(32) DEFAULT NULL COMMENT '本位币 数据字典配置',

  `ESCO_FINANCE_CODE` VARCHAR(32) DEFAULT NULL COMMENT '财务代码',

  `ESCO_STATUS` VARCHAR(32) DEFAULT NULL COMMENT '平台状态 数据字典配置',

  `ESCO_CDH_CODE` VARCHAR(32) DEFAULT NULL COMMENT 'CDH接口代码',

  `ESCO_SUBSTR1` TEXT COMMENT '预留字段',

  `ESCO_SUBSTR2` TEXT COMMENT '预留字段',

  `ESCO_SUBSTR3` TEXT COMMENT '预留字段',

  `ESCO_SUBSTR4` TEXT COMMENT '预留字段',

  `ESCO_SUBSTR5` TEXT COMMENT '预留字段',

  `ESCO_SUBSTR6` TEXT COMMENT '预留字段',

  `ESCO_SUBSTR7` TEXT COMMENT '预留字段',

  `ESCO_SUBSTR8` TEXT COMMENT '预留字段',

  `ESCO_SUBDATE1` DATETIME DEFAULT NULL COMMENT '预留字段',

  `ESCO_SUBDATE2` DATETIME DEFAULT NULL COMMENT '预留字段',

  `ESCO_SUBDATE3` DATETIME DEFAULT NULL COMMENT '预留字段',

  `ESCO_SUBDATE4` DATETIME DEFAULT NULL COMMENT '预留字段',

  `ESCO_SUBDATE5` DATETIME DEFAULT NULL COMMENT '预留字段',

  `ESCO_SUBNUM1` DECIMAL(65,30) DEFAULT NULL COMMENT '预留字段',

  `ESCO_SUBNUM2` DECIMAL(65,30) DEFAULT NULL COMMENT '预留字段',

  `ESCO_SUBNUM3` DECIMAL(65,30) DEFAULT NULL COMMENT '预留字段',

  `REC_VER` DECIMAL(12,0) NOT NULL COMMENT '时间戳',

  `CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',

  `CREATOR` VARCHAR(64) NOT NULL COMMENT '创建人',

  `MODIFY_TIME` DATETIME NOT NULL COMMENT '修改时间',

  `MODIFIER` VARCHAR(64) NOT NULL COMMENT '修改人',

  `ESCO_PATH` TEXT COMMENT '路径',

  `ESCO_EBPL_CITY_CODE` VARCHAR(32) DEFAULT NULL COMMENT '市',

  `ESCO_ACCOUNT_RULE` VARCHAR(36) DEFAULT NULL COMMENT '规则代码',

  `ESCO_LOGO_BACKUP` LONGBLOB COMMENT '公司logo文件',

  `ESCO_ACCOUNT_RULE_NAME` VARCHAR(128) DEFAULT NULL COMMENT '规则名称',

  `ESCO_LOGO` VARCHAR(128) DEFAULT NULL COMMENT 'logo',

  `ESCO_REGION` TEXT COMMENT '所属区域',

  PRIMARY KEY (`ESCO_ID`) USING BTREE

) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='平台信息表' shardkey=noshardkey_allset;

CREATE TABLE `eb_place` (

  `EBPL_ID` BIGINT(12) NOT NULL AUTO_INCREMENT COMMENT '区域表主键',

  `EBPL_TYPE` VARCHAR(32) DEFAULT NULL COMMENT '地点级别',

  `EBPL_CODE` VARCHAR(32) DEFAULT NULL COMMENT '代码',

  `EBPL_QUICK_CODE` VARCHAR(32) DEFAULT NULL COMMENT '快速录入码',

  `EBPL_NAME_CN` VARCHAR(64) DEFAULT NULL COMMENT '中文名称',

  `EBPL_NAME_EN` VARCHAR(64) DEFAULT NULL COMMENT '英文名称',

  `EBPL_POST_CODE` VARCHAR(32) DEFAULT NULL COMMENT '邮编',

  `EBPL_IS_ABLE` VARCHAR(32) DEFAULT NULL COMMENT '是否可用',

  `EBPL_SUBSTR1` TEXT COMMENT '预留字段',

  `EBPL_SUBSTR2` TEXT COMMENT '预留字段',

  `EBPL_SUBSTR3` TEXT COMMENT '预留字段',

  `EBPL_SUBSTR4` TEXT COMMENT '预留字段',

  `EBPL_SUBSTR5` TEXT COMMENT '预留字段',

  `EBPL_SUBSTR6` TEXT COMMENT '预留字段',

  `EBPL_SUBSTR8` TEXT COMMENT '预留字段',

  `EBPL_SUBSTR7` TEXT COMMENT '预留字段',

  `EBPL_SUBDATE1` DATETIME DEFAULT NULL COMMENT '预留字段',

  `EBPL_SUBDATE2` DATETIME DEFAULT NULL COMMENT '预留字段',

  `EBPL_SUBDATE5` DATETIME DEFAULT NULL COMMENT '预留字段',

  `EBPL_SUBDATE4` DATETIME DEFAULT NULL COMMENT '预留字段',

  `EBPL_SUBDATE3` DATETIME DEFAULT NULL COMMENT '预留字段',

  `EBPL_SUBNUM1` DECIMAL(65,30) DEFAULT NULL COMMENT '预留字段',

  `EBPL_SUBNUM2` DECIMAL(65,30) DEFAULT NULL COMMENT '预留字段',

  `EBPL_SUBNUM3` DECIMAL(65,30) DEFAULT NULL COMMENT '预留字段',

  `REC_VER` DECIMAL(12,0) NOT NULL COMMENT '时间戳',

  `CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',

  `MODIFY_TIME` DATETIME NOT NULL COMMENT '修改时间',

  `MODIFIER` VARCHAR(64) NOT NULL COMMENT '修改人',

  `CREATOR` VARCHAR(64) NOT NULL COMMENT '创建人',

  `EBPL_STATION_CODE` VARCHAR(32) DEFAULT NULL COMMENT '所属基地代码',

  `EBPL_STATION_NAME` VARCHAR(64) DEFAULT NULL COMMENT '所属基地',

  `EBPL_PARENT_PM_CODE` VARCHAR(32) DEFAULT NULL COMMENT '上级地点code',

  `EBPL_AREA_NUMBER` VARCHAR(32) DEFAULT NULL COMMENT '地区区号',

  PRIMARY KEY (`EBPL_ID`) USING BTREE,

  KEY `INX_EBPL_EBPL_CODE` (`EBPL_CODE`) USING BTREE

) ENGINE=INNODB AUTO_INCREMENT=10000007002 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='地点表' shardkey=noshardkey_allset;

CREATE TABLE `lsp_service_supplier_type` (

  `LSST_ID` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键',

  `PM_CODE` VARCHAR(32) DEFAULT NULL COMMENT 'PM_CODE',

  `LSST_LSSU_PM_CODE` VARCHAR(32) DEFAULT NULL COMMENT '供应商表PMCODE',

  `LSST_TYPE_CODE` VARCHAR(32) DEFAULT NULL COMMENT '服务供应商类型CODE',

  `LSST_TYPE_NAME` VARCHAR(64) DEFAULT NULL COMMENT '服务供应商类型名称',

  `REC_VER` INT(11) NOT NULL COMMENT '时间戳',

  `CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',

  `CREATOR` VARCHAR(36) NOT NULL COMMENT '创建人',

  `MODIFY_TIME` DATETIME NOT NULL COMMENT '修改时间',

  `MODIFIER` VARCHAR(36) NOT NULL COMMENT '修改人',

  `REC_STATUS` TINYINT(4) DEFAULT NULL COMMENT '行状态',

  `ORG_ID` VARCHAR(20) DEFAULT NULL COMMENT '分公司代码',

  `TIME_ZONE` VARCHAR(20) DEFAULT NULL COMMENT '时区',

  PRIMARY KEY (`LSST_ID`) USING BTREE,

  KEY `IDX_L_OP` (`PM_CODE`,`ORG_ID`) USING BTREE,

  KEY `index_LSST_TYPE_CODE` (`LSST_TYPE_CODE`,`LSST_LSSU_PM_CODE`,`ORG_ID`) USING BTREE,

  KEY `IDX_LSSU_PM_CODE` (`LSST_LSSU_PM_CODE`) USING BTREE

) ENGINE=INNODB AUTO_INCREMENT=102003 DEFAULT CHARSET=utf8 COMMENT='服务供应商类型表' shardkey=noshardkey_allset;

CREATE TABLE `lsp_supplier` (

  `LSSU_ID` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键',

  `PM_CODE` VARCHAR(32) DEFAULT NULL COMMENT '供应商编码',

  `LSSU_SUPPLIER_CODE` VARCHAR(32) DEFAULT NULL COMMENT '供应商代码',

  `LSSU_SUPPLIER_NAME` VARCHAR(128) DEFAULT NULL COMMENT '供应商名称',

  `LSSU_PLATFORM_NATURE` VARCHAR(32) DEFAULT NULL COMMENT '公司性质',

  `LSSU_EBPL_CITY_CODE` VARCHAR(32) DEFAULT NULL COMMENT '市代码',

  `LSSU_EBPL_CITY_NAME` VARCHAR(64) DEFAULT NULL COMMENT '市名称',

  `LSSU_STATUS` VARCHAR(32) DEFAULT NULL COMMENT '状态',

  `LSSU_ADDRESS_CODE` VARCHAR(32) DEFAULT NULL COMMENT '地址代码',

  `LSSU_ADDRESS` VARCHAR(128) DEFAULT NULL COMMENT '地址',

  `LSSU_OFFICE_AREA` DECIMAL(18,8) DEFAULT NULL COMMENT '办公面积',

  `LSSU_OPERATING_AREA` DECIMAL(18,8) DEFAULT NULL COMMENT '营运面积',

  `LSSU_OWN_VEH_NUM` DECIMAL(10,0) DEFAULT NULL COMMENT '自有车辆数',

  `LSSU_VEHICLE_LOAD` VARCHAR(128) DEFAULT NULL COMMENT '车辆载位',

  `LSSU_AVE_VEH_AGE` DECIMAL(18,8) DEFAULT NULL COMMENT '平均车龄',

  `LSSU_DRIVER_NUM` DECIMAL(10,0) DEFAULT NULL COMMENT '司机数量',

  `LSSU_AVE_DRIVER_AGE` DECIMAL(18,8) DEFAULT NULL COMMENT '平均驾龄',

  `LSSU_BUSINESS_CONTACT` VARCHAR(128) DEFAULT NULL COMMENT '业务联系人',

  `LSSU_TEL` VARCHAR(32) DEFAULT NULL COMMENT '联系人电话',

  `LSSU_EMAIL` VARCHAR(64) DEFAULT NULL COMMENT '联系人邮箱',

  `LSSU_COVERAGE_AREA` VARCHAR(128) DEFAULT NULL COMMENT '覆盖范围',

  `LSSU_BINDING_ACCOUNT` VARCHAR(64) DEFAULT NULL COMMENT '绑定账号',

  `LSSU_COMPANY_REGISTRATION_NO` VARCHAR(64) DEFAULT NULL COMMENT '工商登记号',

  `LSSU_TAX_REGIST_NO` VARCHAR(64) DEFAULT NULL COMMENT '税务登记号',

  `LSSU_ROAD_TRANS_CHECK` CHAR(1) DEFAULT NULL COMMENT '道路运输许可',

  `LSSU_LEGAL_QUALIFICATION` CHAR(1) DEFAULT NULL COMMENT '法人资质',

  `LSSU_SUPPLIER_TYPE` VARCHAR(32) DEFAULT NULL COMMENT '所属类别(HS公路、空运、铁路、海运、集配、服务商)',

  `REC_VER` DECIMAL(20,0) DEFAULT NULL COMMENT '时间戳',

  `CREATE_TIME` DATETIME DEFAULT NULL COMMENT '创建时间',

  `CREATOR` VARCHAR(36) DEFAULT NULL COMMENT '创建人',

  `MODIFY_TIME` DATETIME DEFAULT NULL COMMENT '修改时间',

  `MODIFIER` VARCHAR(36) DEFAULT NULL COMMENT '修改人',

  `REC_STATUS` DECIMAL(1,0) DEFAULT NULL COMMENT '行状态',

  `ORG_ID` VARCHAR(20) DEFAULT NULL COMMENT '分公司代码',

  `TIME_ZONE` VARCHAR(20) DEFAULT NULL COMMENT '时区',

  `LSSU_ESTABLISHMENT_DATE` DATETIME DEFAULT NULL COMMENT '成立时间',

  `LSSU_REG_CAPITAL` DECIMAL(18,8) DEFAULT NULL COMMENT '注册资金',

  `LSSU_WAREHOUSE_AREA` DECIMAL(18,8) DEFAULT NULL COMMENT '仓库面积/堆场面积',

  `LSSU_EMP_NUM` DECIMAL(65,30) DEFAULT NULL COMMENT '员工人数',

  `LSSU_CONTAINER_CAR_QUANTITY` DECIMAL(65,30) DEFAULT NULL COMMENT '货柜车数量',

  `LSSU_REMAKE` TEXT COMMENT '备注',

  `LSSU_CORPORATE_REPRESENTATIVE` VARCHAR(128) DEFAULT NULL COMMENT '法人代表',

  `LSSU_TAX_REGIST_TYPE` VARCHAR(12) DEFAULT NULL COMMENT '税务登记类型',

  `LSSU_BUSINESS_TYPE` VARCHAR(12) DEFAULT NULL COMMENT '行业类型CODE',

  `LSSU_SUPPLIER_CATEGORY` VARCHAR(32) DEFAULT NULL COMMENT '供应商类型',

  `LSSU_SUPERIOR_SUPPLIER_CODE` VARCHAR(32) DEFAULT NULL COMMENT '上级供应商代码',

  `LSSU_SUPERIOR_SUPPLIER_NAME` VARCHAR(64) DEFAULT NULL COMMENT '上级供应商名称',

  `LSSU_IS_DIRECT_DISPATCH_DRIVER` CHAR(1) DEFAULT NULL COMMENT '可直接调度司机',

  `LSSU_ISSUE_TYPE` VARCHAR(32) DEFAULT NULL COMMENT '下方方式',

  `LSSU_SUPPLIER_NO` VARCHAR(32) DEFAULT NULL COMMENT '供应商编号',

  `LSSU_IS_SETTLEMENT` CHAR(1) DEFAULT NULL COMMENT '是否结算方',

  `LSSU_DANGEROUS_LEVEL_CODE` VARCHAR(64) DEFAULT NULL COMMENT '是否可承运危险品等级CODE',

  `LSSU_PARENT_SUPPLIER_CODE` VARCHAR(32) DEFAULT NULL COMMENT '父供应商代码',

  `LSSU_PARENT_SUPPLIER_NAME` VARCHAR(64) DEFAULT NULL COMMENT '父供应商名称',

  `LSSU_APPOINTMENT` VARCHAR(2) DEFAULT NULL COMMENT '是否手工预约',

  `LSSU_CONFIRM` VARCHAR(2) DEFAULT NULL COMMENT '入园确认标识',

  `LSSU_EXTERNAL_SUPPLIER_CODE` VARCHAR(32) DEFAULT NULL COMMENT '外部供应商编码',

  `LSSU_EXTERNAL_SUPPLIER_NAME` VARCHAR(64) DEFAULT NULL COMMENT '外部供应商名称',

  `LSSU_ACCOUNT` VARCHAR(64) DEFAULT NULL COMMENT '银行账号',

  `LSSU_ACCOUNT_NO` VARCHAR(64) DEFAULT NULL COMMENT '银行代码',

  `LSSU_ACCOUNT_BANK` VARCHAR(128) DEFAULT NULL COMMENT '开户行',

  `LSSU_ACCOUNT_NAME` VARCHAR(128) DEFAULT NULL COMMENT '户名',

  `LSSU_ACCOUNT_PROVINCE` VARCHAR(32) DEFAULT NULL COMMENT '开户行所在省',

  `LSSU_ACCOUNT_CITY` VARCHAR(32) DEFAULT NULL COMMENT '开户行所在市',

  `LSSU_CLIENT` VARCHAR(32) DEFAULT NULL COMMENT '客户端',

  `LSSU_PURCHASE_LEADER` VARCHAR(64) DEFAULT NULL COMMENT '采购负责人',

  `LSSU_PURCHASE_ORGANIZATION` VARCHAR(64) DEFAULT NULL COMMENT '采购组织',

  `LSSU_ACCOUNT_GROUP` VARCHAR(32) DEFAULT NULL COMMENT '账户组',

  `OWNER_TF` VARCHAR(32) DEFAULT NULL COMMENT '是否可货权转移',

  `LSSU_PROPERTIES` VARCHAR(32) DEFAULT NULL COMMENT '供应商属性(外部、联营、母子)',

  PRIMARY KEY (`LSSU_ID`) USING BTREE,

  KEY `IDX_L_OP` (`PM_CODE`,`ORG_ID`) USING BTREE,

  KEY `INX_LSSU_LSSU_SUPPLIER_NO` (`LSSU_SUPPLIER_NO`) USING BTREE,

  KEY `INX_LSSU_LSSU_SUPPLIER_NO_NAME` (`LSSU_SUPPLIER_NO`,`LSSU_SUPPLIER_NAME`) USING BTREE,

  KEY `INX_LSSU_MODIFY_TIME` (`MODIFY_TIME`) USING BTREE,

  KEY `LS_LA` (`LSSU_APPOINTMENT`) USING BTREE,

  KEY `LS_LLRL` (`LSSU_APPOINTMENT`,`REC_STATUS`,`LSSU_SUPPLIER_TYPE`,`LSSU_STATUS`) USING BTREE,

  KEY `IDX_LSSU_PMCODE` (`PM_CODE`,`LSSU_SUPPLIER_NAME`,`LSSU_SUPPLIER_NO`,`ORG_ID`) USING BTREE,

  KEY `IDX_TEST1` (`LSSU_SUPPLIER_NO`) USING BTREE,

  KEY `IDX_LSSU_PMCODE_ORG_ID` (`LSSU_STATUS`,`PM_CODE`,`ORG_ID`) USING BTREE

) ENGINE=INNODB AUTO_INCREMENT=145552 DEFAULT CHARSET=utf8 COMMENT='供应商管理' shardkey=noshardkey_allset;

CREATE TABLE `eb_code_master` (

  `EBCD_ID` bigint(20) NOT NULL AUTO_INCREMENT,

  `EBCD_ESCO_ID` int(11) DEFAULT NULL COMMENT '所属公司',

  `EBCD_EBPJ_ID` int(11) DEFAULT NULL COMMENT '所属项目',

  `EBCD_QUICK_CODE` varchar(32) DEFAULT NULL COMMENT '快速录入码',

  `EBCD_DICTIONARY_TYPE` varchar(32) DEFAULT NULL COMMENT '字典类型',

  `EBCD_CODE` varchar(32) DEFAULT NULL COMMENT '代码',

  `EBCD_NAME_EN` text COMMENT '英文名称',

  `EBCD_NAME_CN` text COMMENT '中文名称',

  `EBCD_LEVEL_TYPE` int(65) DEFAULT NULL COMMENT '级别类型',

  `EBCD_SQUENCE_NO` int(65) DEFAULT NULL COMMENT '排序号',

  `EBCD_DESC` text COMMENT '描述',

  `EBCD_STATUS` char(1) DEFAULT NULL COMMENT '状态:1标识正常,2标识删除\n ',

  `EBCD_SUBSTR1` text COMMENT '预留字段',

  `EBCD_SUBSTR2` text COMMENT '预留字段',

  `EBCD_SUBSTR3` text COMMENT '预留字段',

  `EBCD_SUBSTR4` text COMMENT '预留字段',

  `EBCD_SUBSTR5` text COMMENT '预留字段',

  `EBCD_SUBSTR6` text COMMENT '预留字段',

  `EBCD_SUBSTR8` text COMMENT '预留字段',

  `EBCD_SUBSTR7` text COMMENT '预留字段',

  `EBCD_SUBDATE1` datetime DEFAULT NULL COMMENT '预留字段',

  `EBCD_SUBDATE2` datetime DEFAULT NULL COMMENT '预留字段',

  `EBCD_SUBDATE5` datetime DEFAULT NULL COMMENT '预留字段',

  `EBCD_SUBDATE4` datetime DEFAULT NULL COMMENT '预留字段',

  `EBCD_SUBDATE3` datetime DEFAULT NULL COMMENT '预留字段',

  `EBCD_SUBNUM3` decimal(65,30) DEFAULT NULL COMMENT '预留字段',

  `EBCD_SUBNUM2` decimal(65,30) DEFAULT NULL COMMENT '预留字段',

  `EBCD_SUBNUM1` decimal(65,30) DEFAULT NULL COMMENT '预留字段',

  `REC_VER` int(11) NOT NULL COMMENT '时间戳',

  `CREATOR` varchar(64) NOT NULL COMMENT '创建人',

  `CREATE_TIME` datetime NOT NULL COMMENT '创建时间',

  `MODIFIER` varchar(64) NOT NULL COMMENT '修改人',

  `MODIFY_TIME` datetime NOT NULL COMMENT '修改时间',

  `PM_CODE` varchar(32) DEFAULT NULL COMMENT '代码',

  PRIMARY KEY (`EBCD_ID`) USING BTREE,

  KEY `IDX_ECM_EE` (`EBCD_DICTIONARY_TYPE`,`EBCD_STATUS`) USING BTREE,

  KEY `INX_CODE` (`EBCD_CODE`) USING BTREE

) ENGINE=InnoDB AUTO_INCREMENT=10105004 DEFAULT CHARSET=utf8 COMMENT='数字字典表 存放系统中下拉框,复选框的值' shardkey=noshardkey_allset;

SELECT

  LSSU.LSSU_ID, LSSU.LSSU_SUPPLIER_NO, LSSU.PM_CODE, LSSU.LSSU_SUPPLIER_CODE, LSSU.LSSU_SUPPLIER_NAME, LSSU.LSSU_PLATFORM_NATURE, LSSU.LSSU_EBPL_CITY_CODE, LSSU.LSSU_EBPL_CITY_NAME, LSSU.LSSU_STATUS, LSSU.LSSU_ADDRESS_CODE, LSSU.LSSU_ADDRESS, LSSU.LSSU_OFFICE_AREA, LSSU.LSSU_OPERATING_AREA, LSSU.LSSU_OWN_VEH_NUM, LSSU.LSSU_VEHICLE_LOAD, LSSU.LSSU_AVE_VEH_AGE, LSSU.LSSU_DRIVER_NUM, LSSU.LSSU_AVE_DRIVER_AGE, LSSU.LSSU_BUSINESS_CONTACT, LSSU.LSSU_TEL, LSSU.LSSU_EMAIL, LSSU.LSSU_COVERAGE_AREA, LSSU.LSSU_BINDING_ACCOUNT, LSSU.LSSU_COMPANY_REGISTRATION_NO, LSSU.LSSU_TAX_REGIST_NO, LSSU.LSSU_ROAD_TRANS_CHECK, LSSU.LSSU_LEGAL_QUALIFICATION, LSSU.LSSU_SUPPLIER_TYPE, LSSU.REC_VER, LSSU.CREATE_TIME, LSSU.CREATOR, LSSU.MODIFY_TIME, LSSU.MODIFIER, LSSU.REC_STATUS, LSSU.ORG_ID, LSSU.TIME_ZONE, LSSU.LSSU_ESTABLISHMENT_DATE, LSSU.LSSU_REG_CAPITAL, LSSU.LSSU_WAREHOUSE_AREA, LSSU.LSSU_EMP_NUM, LSSU.LSSU_CONTAINER_CAR_QUANTITY, LSSU.LSSU_REMAKE, LSSU.LSSU_CORPORATE_REPRESENTATIVE, LSSU.LSSU_TAX_REGIST_TYPE, LSSU.LSSU_BUSINESS_TYPE, LSSU.LSSU_SUPPLIER_CATEGORY, LSSU.LSSU_ISSUE_TYPE, LSSU.LSSU_IS_SETTLEMENT, LSSU.LSSU_SUPERIOR_SUPPLIER_CODE, LSSU.LSSU_SUPERIOR_SUPPLIER_NAME, LSSU.LSSU_IS_DIRECT_DISPATCH_DRIVER, LSSU.LSSU_APPOINTMENT, LSSU.LSSU_CONFIRM, LSSU.LSSU_EXTERNAL_SUPPLIER_CODE, LSSU.LSSU_EXTERNAL_SUPPLIER_NAME, LSSU.LSSU_ACCOUNT, LSSU.LSSU_ACCOUNT_NO, LSSU.LSSU_ACCOUNT_BANK, LSSU.LSSU_ACCOUNT_NAME, LSSU.LSSU_ACCOUNT_PROVINCE, LSSU.LSSU_ACCOUNT_CITY, LSSU.LSSU_CLIENT, LSSU.LSSU_PARENT_SUPPLIER_CODE, LSSU.LSSU_PARENT_SUPPLIER_NAME, LSSU.LSSU_PURCHASE_LEADER, LSSU.LSSU_PURCHASE_ORGANIZATION, LSSU.LSSU_ACCOUNT_GROUP, LSSU.OWNER_TF, LSSU.LSSU_PROPERTIES, NULL AS IS_NEW,

  (SELECT

    EBLC_COUNTRY_CODE

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_COUNTRY_CODE,

  (SELECT

    EBLC_COUNTRY_NAME

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_COUNTRY_NAME,

  (SELECT

    EBLC_PROVINCE_CODE

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_PROVINCE_CODE,

  (SELECT

    EBLC_PROVINCE_NAME

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_PROVINCE_NAME,

  (SELECT

    EBLC_CITY_CODE

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_CITY_CODE,

  (SELECT

    EBLC_CITY_NAME

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_CITY_NAME,

  (SELECT

    EBLC_COUNTY_CODE

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_COUNTY_CODE,

  (SELECT

    EBLC_COUNTY_NAME

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_COUNTY_NAME,

  (SELECT

    EBLC_LATITUDE

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_LATITUDE,

  (SELECT

    EBLC_LONGITUDE

  FROM

    EB_LOCATION EBLC

  WHERE 1 = 1

    AND EBLC.EBLC_CODE = LSSU.LSSU_ADDRESS_CODE

    AND EBLC.ORG_ID = LSSU.ORG_ID

    AND EBLC.REC_STATUS = 0

  LIMIT 1) AS EBLC_LONGITUDE,

  (SELECT

    ESCO_COMPANY_NAME_CN

  FROM

    ES_COMPANY ESCO

  WHERE 1 = 1

    AND ESCO.ESCO_ID = LSSU.ORG_ID

  LIMIT 1) AS ESCO_COMPANY_NAME,

  (SELECT

    EBPL_NAME_CN

  FROM

    EB_PLACE province

  WHERE 1 = 1

    AND province.ebpl_code = LSSU.LSSU_ACCOUNT_PROVINCE

  LIMIT 1) AS lssu_Account_Province_Name,

  (SELECT

    EBPL_NAME_CN

  FROM

    EB_PLACE province

  WHERE 1 = 1

    AND province.ebpl_code = LSSU.Lssu_Account_city

  LIMIT 1) AS lssu_Account_City_Name,

  (SELECT

    CAST(

      GROUP_CONCAT(EBCD.EBCD_NAME_CN) AS CHAR

    )

  FROM

    LSP_SERVICE_SUPPLIER_TYPE LSST

    LEFT JOIN EB_CODE_MASTER EBCD

      ON EBCD.EBCD_CODE = LSST.LSST_TYPE_CODE

      AND EBCD.EBCD_DICTIONARY_TYPE = 'SYS_SERVICE_SUPPLIER_TYPE'

  WHERE 1 = 1

    AND LSST.LSST_LSSU_PM_CODE = LSSU.Pm_Code

    AND LSST.ORG_ID = LSSU.ORG_ID

    AND EBCD.EBCD_STATUS = 1

  LIMIT 1) AS EBCD_NAME_CNS,

  (SELECT

    CAST(

      GROUP_CONCAT(EBCD.EBCD_NAME_EN) AS CHAR

    )

  FROM

    LSP_SERVICE_SUPPLIER_TYPE LSST

    LEFT JOIN EB_CODE_MASTER EBCD

      ON EBCD.EBCD_CODE = LSST.LSST_TYPE_CODE

      AND EBCD.EBCD_DICTIONARY_TYPE = 'SYS_SERVICE_SUPPLIER_TYPE'

  WHERE 1 = 1

    AND LSST.LSST_LSSU_PM_CODE = LSSU.Pm_Code

    AND LSST.ORG_ID = LSSU.ORG_ID

    AND EBCD.EBCD_STATUS = 1

  LIMIT 1) AS EBCD_NAME_ENS,

  (SELECT

    CAST(

      GROUP_CONCAT(EBCD.EBCD_CODE) AS CHAR

    )

  FROM

    LSP_SERVICE_SUPPLIER_TYPE LSST

    LEFT JOIN EB_CODE_MASTER EBCD

      ON EBCD.EBCD_CODE = LSST.LSST_TYPE_CODE

      AND EBCD.EBCD_DICTIONARY_TYPE = 'SYS_SERVICE_SUPPLIER_TYPE'

  WHERE 1 = 1

    AND LSST.LSST_LSSU_PM_CODE = LSSU.Pm_Code

    AND LSST.ORG_ID = LSSU.ORG_ID

    AND EBCD.EBCD_STATUS = 1

  LIMIT 1) AS EBCD_CODES

FROM

  LSP_SUPPLIER LSSU

ORDER BY lssu.MODIFY_TIME DESC

LIMIT  0, 10;

你可能感兴趣的:(数据库复杂SQL语句)