David that was spot on thanks!
Helped to clear up some things in my mind. Maybe you could help me with the following:
I am now trying to show all messages which have updates from the submitter of the message and are not new (ie have more than one message)
Here is the SQL that accomplishes showing the max message in a thread that was inserted my the submitter:
SELECT
t2.MESSAGEID
FROM tbl_CONTACT_message t1
INNER JOIN
tbl_CONTACT_message_thread t2
on t1.MESSAGEID = t2.MESSAGEID where t2.THREADID = (SELECT MAX(THREADID) FROM tbl_CONTACT_message_thread WHERE MESSAGEID = t1.MESSAGEID and t2.isadmin = 0)
To achieve this in LLGBL what I tried was the following:
filter.Add(new FieldCompareSetPredicate(ContactMessageThreadFields.Threadid, null, ContactMessageThreadFields.Threadid.SetAggregateFunction(AggregateFunction.Max), null, SetOperator.Equal, (ContactMessageFields.Messageid == ContactMessageThreadFields.Messageid)));
But I am getting an Index was outside the bounds of the array exception.
The last part of the query would be to exclude the results of the first query you helped me with - ie to ignore new messages (those with one thread).
Cheers for your time!