SQL 查询优化:解决子查询未别名错误
{"title":"select date(create_time),count(id)\nfrom \n(select \n\tid,request_params,response_params,JSON_EXTRACT(response_params, '$.message') as fz,create_time\nfrom cl_sms_log\nwhere date(create_time) >= '2023-01-01')a --过滤回填短信 \nwhere fz is not null\ngroup by 1报错内容:The error in your query is because you are using a subquery without aliasing it. You need to provide an alias for the subquery.\n\nHere's the corrected query:\n\nsql\nSELECT DATE(create_time), COUNT(id)\nFROM \n(\n SELECT \n id, request_params, response_params, JSON_EXTRACT(response_params, '$.message') AS fz, create_time\n FROM cl_sms_log\n WHERE DATE(create_time) >= '2023-01-01'\n) AS a -- alias for the subquery\nWHERE fz IS NOT NULL\nGROUP BY 1\n"}
原文地址: https://www.cveoy.top/t/topic/pvmH 著作权归作者所有。请勿转载和采集!