兩張表。一個包含項目列表,另一個包含項目的階段。 我需要展示項目的最新階段。 的SQL我此刻正顯示所有階段,看起來是這樣的:加入限制結果
SELECT
a.proj_name,
a.proj_phase,
c.proj_actions_next_action,
c.proj_actions_next_action_date
FROM
projects a
LEFT OUTER JOIN
Projects_actions c
ON a.proj_id = c.proj_actions_projects_link
LEFT OUTER JOIN
Clients b
ON a.proj_clientlink = b.client_id
ORDER BY b.clientname
輸出看起來是這樣的:
proj_name | proj_phase | proj_actions_next_action | proj_actions_next_action_date
Denmark | Active | Call X person | 1/1/2014
Denmark | Active | Call Y person | 2/1/2014
Denmark | Active | Do this presentation | 3/1/2014
Denmark | Active | Sell this product | 4/1/2014
UK Asset | Active | Call Y person | 1/2/2014
UK Asset | Active | Call X person | 1/3/2014
UK Asset | Active | Call Y person | 2/4/2014
UK Asset | Active | Do this presentation | 3/5/2014
UK Asset | Active | Sell this product | 4/6/2014
我希望它看起來是這樣的:(只顯示最新的proj_actions_next_action_date)
proj_name | proj_phase | proj_actions_next_action | proj_actions_next_action_date
Denmark | Active | Sell this product | 4/1/2014
UK Asset | Active | Sell this product | 4/6/2014
謝謝大家!
剛剛得到的最大(日期)出來。 – Divya