sql=" select abc.a,abc.b,abc.c,abc.d,abc.h ,abc.f from"
sql=sql+" ( select t3005.p_code as a,"
sql=sql+" t3017.c_name as b,"
sql=sql+" t3020.rank_name as c,"
sql=sql+" t3005.fly_hours as d,"
sql=sql+" t3020.rank_no as e,"
sql=sql+" t3005.flight_date as f,"
sql=sql+" T3035.EXAM_DATE as g , decode(T3035.RESULT, '1', '已完成', '2', '未通过', '--') as h "
sql=sql+" from t3005,"
sql=sql+" t3017,t3035,"
sql=sql+" t3020"
sql=sql+" where (t3005.crew_link_line='" & crew_link & "') and "
sql=sql+" (t3005.p_code=t3017.p_code) and "
sql=sql+" (t3005.p_code=t3035.p_code) and "
sql=sql+" (t3005.flight_date=t3035.EXAM_DATE) and "
sql=sql+" (t3005.rank_no=t3020.rank_no) and "
sql=sql+" (To_Char(t3005.flight_date,'YYYY-MM-DD')='" & sDay & "')"
sql=sql+" union all "
sql=sql+" select t3016.p_code as a,"
sql=sql+" t3017.c_name as b,"
sql=sql+" t3020.rank_name as c,"
sql=sql+" t3016.fly_hours as d,"
sql=sql+" t3020.rank_no as e,"
sql=sql+" t3016.flight_date as f, null as g , null as h "
sql=sql+" from t3016,"
sql=sql+" t3017,"
sql=sql+" t3020 "
sql=sql+" where (t3016.stew_link_line='" & stew_link & "') and "
sql=sql+" (t3017.p_code=t3016.p_code) and "
sql=sql+" (t3020.rank_no=t3016.rank_no) and "
sql=sql+" (To_Char(t3016.flight_date,'YYYY-MM-DD')='" & sDay & "') ) abc"
sql=sql+" order by abc.e"
select 字段(7个的) from ....
union
select 5个字段,''(0) as 7个字段中的另两个字段之一,''(0) as 7个字段的中的最后一个 from .....可要注意前一个Select的字段排列要与后面的字段排序顺序一样。
并且字段类型也要一样。
如果字段类型为数字之类的,可不能用''还要用0绝对不会错