我有一个查询返回类似的内容:
Name Gender Job date of hire
John M mechanic 2012-05-08
John M electrician 2010-01-01
Vicky F scientific 2012-11-11
Bob M NULL NULL
Run Code Online (Sandbox Code Playgroud)
我需要每个人的第一份工作的姓名、性别和工作名称。但我不知道怎么做。我的查询如下所示:
select name,gender,jobname,hiredate
from person p
left join job j on p.personid = j.personid
Run Code Online (Sandbox Code Playgroud)
我使用的是 Microsoft SQL Server 2000
我需要这个结果:
Name Gender Job
John M electrician
Vicky F scientific
Bob M NULL
Run Code Online (Sandbox Code Playgroud)