別名添加到組在下面的查詢如何添加別名assignedTOiti
,assignedTOasstAdm
,assignedTOhlp
,closedDate
到group by子句。如何by子句
我在過去的幾個小時掙扎着。
SELECT ieor.aper07_req_k AS reqno,
ford.apeh09_supervisor_cds_d AS ll6CdsID,
'Ford Offboard Req' AS reqtype,
par_val1.aper17_parameter_val_x AS requeststatus,
(SELECT Min(iti2.aper07_req_created_s)
FROM iaper07_employee_offbrd_req iti2
WHERE ieor.aper07_req_k = iti2.aper07_req_k
AND iti2.aper06_req_status_k = 4) AS assignedTOiti,
(SELECT Min(hlp2.aper07_req_created_s)
FROM iaper07_employee_offbrd_req hlp2
WHERE ieor.aper07_req_k = hlp2.aper07_req_k
AND hlp2.aper06_req_status_k = 5) AS assignedTOasstAdm,
(SELECT Min(asst2.aper07_req_created_s)
FROM iaper07_employee_offbrd_req asst2
WHERE ieor.aper07_req_k = asst2.aper07_req_k
AND asst2.aper06_req_status_k = 12) AS assignedTOhlp,
(SELECT Min(clsd2.aper07_req_created_s)
FROM iaper07_employee_offbrd_req clsd2
WHERE ieor.aper07_req_k = clsd2.aper07_req_k
AND clsd2.aper06_req_status_k IN (3, 9)) AS closedDate,
ieor.aper07_assigned_to_cds_d,
ieor.aper07_comment_x,
ieor.aper07_last_updt_user_c,
ieor.aper07_last_updt_s AS last,
ieor.apeh09_employee_k,
ieor.aper06_req_status_k,
ipw.apeh04_first_n,
ipw.apeh04_cds_d,
ipw.apeh04_last_n,
ipw.apeh04_person_type_c,
irs.aper06_req_status_x,
offr.aper15_offboard_reason_x AS offboardReason,
Min(aper07_req_created_s) AS creationDate
FROM iaper07_employee_offbrd_req ieor,
iapeh05_person_vw ipw,
iapeh09_ford_employee ford,
iaper06_req_status irs,
iaper15_offbrd_req_reason offr,
iaper17_parameter_values par_val1
WHERE ford.apeh09_cds_d = ipw.apeh04_cds_d
AND ieor.apeh09_employee_k = ipw.apeh04_visitor_k
AND irs.aper06_req_status_k = ieor.aper06_req_status_k
AND offr.aper15_offboard_reason_k = ieor.aper15_offboard_reason_k
AND ieor.aper06_req_status_k = par_val1.aper17_parameter_val_r
AND ipw.apeh22_region_k = 1
AND ieor.aper07_last_updt_s = (SELECT Max(aper07_last_updt_s)
FROM iaper07_employee_offbrd_req b
WHERE ieor.aper07_req_k = b.aper07_req_k)
AND ieor.aper07_req_k = 3387
GROUP BY ieor.aper07_req_k,
ford.apeh09_supervisor_cds_d,
ieor.aper07_assigned_to_cds_d,
ieor.aper07_comment_x,
ieor.aper07_last_updt_user_c,
ieor.aper07_last_updt_s,
ieor.apeh09_employee_k,
ieor.aper06_req_status_k,
ipw.apeh04_first_n,
ipw.apeh04_cds_d,
ipw.apeh04_last_n,
ipw.apeh04_person_type_c,
irs.aper06_req_status_x,
par_val1.aper17_parameter_val_x,
offr.aper15_offboard_reason_x
HAVING ipw.apeh04_person_type_c NOT IN('c', 'C')
你能幫助我與UR第二個建議...與關聯到我的query.SInce我的選擇子句在一組不允許由一個子查詢,而不是列。 。其中是什麼我不能做.. – ashwinsakthi
謝謝你這麼much..Florin..but當我實現查詢我得到的一列的空值分配說,以幫助那裏的數據是實際存在的。 – ashwinsakthi
採取內部查詢,刪除哪些是無關的'分配給help',看看什麼是錯的。可能是錯誤的條件,或錯誤的加入。 –