• How would I go about selecting a distinct recid from History?

    While the script below does return the correct data, when we join it on accountno and lastdate, it will include records with identical accountnos and recids (Ie If we've logged calls \ emails to the same contact multiple times on the same day)

    How would I go about getting the recids of the records returned in this script?

    SELECT accountno,MAX(lastdate) AS lastdate

    FROM history

    GROUP BY accountno

    If I had the recids of the history records, I could use them as in the script below...

    SELECT c.Accountno,C.Company, C.Contact,C.Recid,H.lastuser,H.lastdate

    FROM contact C

    LEFT JOIN history h ON C.accountno=h.accountno and h.RECID IN (....

    Any suggestions would be greatly appreciated.