So I'm still trying to learn the ins and outs of modx and xpdo. I'm pretty good with mysql queries, but I'm having some trouble migrating to the xpdo format. I have two tables. The first is a client list, the second is a progress notes table. There is a date field and a contact type. I need to display the last date for direct contact, and the last date of indirect contact. My query looks like:
SELECT ClientFirstName, (
SELECT MAX( ProgDate )
FROM progress
WHERE ClientNum = ClientDirNum
AND (
ProgType =1
)
) AS LastDirectContact, (
SELECT MAX( ProgDate )
FROM progress
WHERE ClientNum = ClientDirNum
AND (
ProgType =3
)
) AS LastInDirectContact
FROM clients
WHERE Employee =16
AND ClientFinished IS NULL
ORDER BY ClientFirstName
Works great, but I'm not sure how to turn this into a union. I looked through the documentation, but only found a brief mention of unions and there were no examples.
Any help would be appreciated.