两张表。一个包含项目列表,另一个包含项目的阶段。 我需要展示项目的最新阶段。 的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