select `id` AS `id` , `opertime` AS `opertime` , `module` AS `module` , `orgname` AS `orgname` , `operuser` AS `operuser` , `opertype` AS `opertype` , `create_time` AS `create_time` , `send_time` AS `send_time` from dljz_approvalrecords
时间: 2023-07-21 15:48:28 浏览: 98
这是一条 SQL 查询语句,它的作用是从表 dljz_approvalrecords 中查询出 id、opertime、module、orgname、operuser、opertype、create_time 和 send_time 这些字段的值。具体含义如下:
- id:记录的唯一标识符;
- opertime:操作时间;
- module:操作模块;
- orgname:机构名称;
- operuser:操作用户;
- opertype:操作类型;
- create_time:记录创建时间;
- send_time:发送时间。
需要注意的是,这条 SQL 查询语句并没有指定任何查询条件,因此会返回 dljz_approvalrecords 表中的所有记录。如果需要根据特定条件查询,则需要添加 WHERE 子句。
相关问题
SELECT p.id AS id, p.fullName AS fullName, p.gender AS gender, p.organizationID AS organizationID, o.ORGNAME AS organizationName, p.mobile AS mobile, WM_CONCAT( j.sworkPlaceName ) AS sworkplaceName FROM base_personfile_person p LEFT JOIN sys_org o ON o.ORGID = p.organizationID LEFT JOIN base_personfile_person_sjob pj ON pj.personId = p.id LEFT JOIN base_personfile_sjob j ON j.ID = pj.sjobId WHERE 1=1 GROUP BY p.id 报不是GROUP BY 表达式
这个错误通常是因为 SELECT 语句中的列与 GROUP BY 子句不匹配。在这种情况下,查询引擎无法确定每个组中应该显示哪些值。
在你的查询中,你使用了 WM_CONCAT 函数来聚合 sworkPlaceName 列,但是你没有在 GROUP BY 子句中包括该列。为了解决这个问题,你需要将 sworkPlaceName 列添加到 GROUP BY 子句中,像这样:
```
SELECT p.id AS id, p.fullName AS fullName, p.gender AS gender, p.organizationID AS organizationID, o.ORGNAME AS organizationName, p.mobile AS mobile, WM_CONCAT(j.sworkPlaceName) AS sworkplaceName
FROM base_personfile_person p
LEFT JOIN sys_org o ON o.ORGID = p.organizationID
LEFT JOIN base_personfile_person_sjob pj ON pj.personId = p.id
LEFT JOIN base_personfile_sjob j ON j.ID = pj.sjobId
GROUP BY p.id, p.fullName, p.gender, p.organizationID, o.ORGNAME, p.mobile
```
这应该会解决你遇到的问题。
SELECT t1.org_id AS sonOrgId, t1.orgName AS sonOrgName, t1.id AS routeBasesectionId, t1.`name` AS routeBasesectionName, t1.nature, zw.billCode AS diseaseTypeSn, COUNT( t3.id ) AS num, ( CASE WHEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) WHEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) ELSE sum( CASE WHEN zw.`status` = '0' THEN zw.workNum END ) END ) AS totalAmount FROM mat_zx_section t3 JOIN base_bridge bb ON bb.id = t3.qshMainId LEFT JOIN mat_zx_workload zw ON zw.mainId = t3.id LEFT JOIN base_e_route_basesection t1 ON t3.baseRoute = t1.id LEFT JOIN main_construct t4 ON t3.constructId = t4.id -- 施工申请 LEFT JOIN main_construct_check t5 ON t5.id = t3.acceptanceId -- 施工申请验收 WHERE t5.process_status = '100' GROUP BY zw.billCode, t1.id, t1.nature, t1.org_id ORDER BY t1.org_id, t1.id, zw.billCode UNION ALL SELECT son_org_id AS sonOrgId, son_org_name AS sonOrgName, route_id AS routeBasesectionId, route_name AS routeBasesectionName, route_type AS nature, disease_type_sn AS diseaseTypeSn, num AS num, total_amount AS totalAmount FROM base_history_repair_statistics;这条sql语句执行失败
这个 SQL 语句可能会因为分号(;)导致执行失败。请尝试将分号(;)删除,然后再次执行该 SQL 语句。如下所示:
```
SELECT t1.org_id AS sonOrgId, t1.orgName AS sonOrgName, t1.id AS routeBasesectionId, t1.`name` AS routeBasesectionName, t1.nature, zw.billCode AS diseaseTypeSn, COUNT( t3.id ) AS num, ( CASE WHEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) WHEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) ELSE sum( CASE WHEN zw.`status` = '0' THEN zw.workNum END ) END ) AS totalAmount FROM mat_zx_section t3 JOIN base_bridge bb ON bb.id = t3.qshMainId LEFT JOIN mat_zx_workload zw ON zw.mainId = t3.id LEFT JOIN base_e_route_basesection t1 ON t3.baseRoute = t1.id LEFT JOIN main_construct t4 ON t3.constructId = t4.id -- 施工申请 LEFT JOIN main_construct_check t5 ON t5.id = t3.acceptanceId -- 施工申请验收 WHERE t5.process_status = '100' GROUP BY zw.billCode, t1.id, t1.nature, t1.org_id ORDER BY t1.org_id, t1.id, zw.billCode UNION ALL SELECT son_org_id AS sonOrgId, son_org_name AS sonOrgName, route_id AS routeBasesectionId, route_name AS routeBasesectionName, route_type AS nature, disease_type_sn AS diseaseTypeSn, num AS num, total_amount AS totalAmount FROM base_history_repair_statistics
```
阅读全文