SELECT top 100 P.ActivityId, -- PhoneCall ID P.Subject, -- PhoneCall Subject -- AP.PartyId, -- Recipient ID con.FullName -- Recipient Name ,l.leadid,l.parentcontactid,con.emailaddress1,ca.createdon,ca.phonenumber FROM ActivityPointer AS P Inner join lead l on p.regardingobjectid=l.leadid --關於是Lead的寫法 inner join contact con on l.parentcontactid=con.contactid inner join phonecall ca on p.ActivityId=ca.ActivityId WHERE P.ActivityTypeCode = 4210 -- PhoneCall Activity Type Code order by ca.createdon desc