2008-12-08 15:26
query="select distinct dwbm,area_no,dwmc,role_no,zgbm_no from s_mtab where role_no between 2 and 3 and (substr(zgbm_no,1,4)='6101' or dwbm=6101) and area_no is not null order by area_no ";
莫名其妙的报错信息。。。“ORA-01791:不是SElECTed表达式” 经分析,如果在ORDER BY中指定多个列,结果将先按照子句中的第一个列排序,然后第二个,依此类推 在 SELECT中未出现的列名也可用于ORDER BY 子句中,主要TABLE中有就行,但如果SELECT子句中出现了DISTINCT关键字,则只能用出现过的列名,而且如果SELECT子句中使用了任何运算符,在ORDER BY 子句中必须保持和SELECT子句中表达式完全一致,否则出现ORA-01791 ERROR 所以分析以后把上面的句子写成这样: query="select distinct area_no, dwbm,dwmc,role_no,zgbm_no from s_mtab where role_no between 2 and 3 and (substr(zgbm_no,1,4)='6101' or dwbm=6101) and area_no is not null order by area_no "; |