sql语句如下:
select distinct(p.project_name) name,p.pkid pkid, p.report_year year, q.cor_name cor_name,getcityname(q.belongs_city) belongs_city,
p.apply_support_funds_num apply_funds, p.total_app_invest total_app_invest, p.invest completed_invest,
get_multi_dict_values('15', p.project_type) project_type,get_multi_dict_values('6', p.declare_type) sb_type
from ydzj_non_finan_audit_status s,ydzj_non_finan_pro_info p,ydzj_non_finan_cor_info q
where p.pkid = s.project_id and p.pkid = q.project_id and s.app_phase = '6' and s.app_status = '2'
order by p.apply_support_funds_num desc, p.completed_invest,p.total_app_invest
执行F8,报错。
把p.invest改成p.completed_invest即正确。
原因是:
如果是select * from table_name order by ...,则order by子句中的字段只要求是table_name表中有的字段即可,但select子句中出现distinct后,order by子句中的字段就
必须在select子句中出现,否则会报错。