SELECT DISTINCT(A.DATA_TYPE)as DATA_TYPE, A.DATA_VALUE as TSL,IFNULL((SELECT B.DATA_VALUE FROM YXDDZH_MIDDLE.GZ_SCREEN_JGSY_SDHJ_SPFW_CITY_AREA_DATA B WHERE B.IS_DELETED = 0 AND B.DATA_DIMENSION = '期末'and B.level=2 and B.DATA_NAME='举报' AND B.DATA_AREA = '市级' AND B.DATA_TYPE=A.DATA_TYPE AND B.DATA_TIME = ( SELECT MAX(DATA_TIME) FROM YXDDZH_MIDDLE.GZ_SCREEN_JGSY_SDHJ_SPFW_CITY_AREA_DATA WHERE IS_DELETED = 0 AND DATA_DIMENSION = '期末'and DATA_NAME='举报'and level=2 AND DATA_AREA = '市级' ) ),0)AS JBL,CURRENT_ID FROM YXDDZH_MIDDLE.GZ_SCREEN_JGSY_SDHJ_SPFW_CITY_AREA_DATA A WHERE A.IS_DELETED = 0 AND A.DATA_DIMENSION = '期末'and A.level=2 and A.DATA_NAME='投诉' AND A.DATA_AREA = '市级' AND A.DATA_TIME = ( SELECT MAX(DATA_TIME) FROM YXDDZH_MIDDLE.GZ_SCREEN_JGSY_SDHJ_SPFW_CITY_AREA_DATA WHERE IS_DELETED = 0 AND DATA_DIMENSION = '期末'and DATA_NAME='投诉'and level=2 AND DATA_AREA = '市级' ) 看看哪里错了
时间: 2024-04-15 20:24:40 浏览: 73
SELECT 的另类用法
根据你提供的SQL查询语句,没有明显的语法错误。但是,请确保以下几点:
1. 确保数据库中的表 `YXDDZH_MIDDLE.GZ_SCREEN_JGSY_SDHJ_SPFW_CITY_AREA_DATA` 存在,并且拥有相应的字段。
2. 确保表中有符合条件的数据,即满足 `IS_DELETED = 0`,`DATA_DIMENSION = '期末'`,`level=2`,`DATA_NAME='投诉'`,`DATA_AREA = '市级'` 的记录。
3. 如果子查询返回多个结果,可能会导致错误,确保子查询只返回一个结果。你可以在子查询前加上 `LIMIT 1` 确保只返回最大的 `DATA_TIME`。
4. 如果以上条件都满足,但仍然遇到问题,请提供更多的错误信息或者具体的错误提示,以便我能更好地帮助你解决问题。
阅读全文