>TEXT TO lcSql TEXTMERGE NOSHOW PRTEXT 15 >SELECT Country.Numero, Country.<<gcReturnTitle>> AS Title, COUNT(DISTINCT School.Numero) >FROM FROM School >JOIN Country ON School.NoCountry=Country.Numero >WHERE School.Status=2 >ORDER BY 2 >ENDTEXT >I'm not sure what field you shoud use in COUNT(DISTINCT School.Numero) because I don't know youtr tables structure/relationship.
IF NOT loDMA.SQLExec('SELECT Country.Numero,Country.'+gcReturnTitle+' AS Title,COUNT(DISTINCT School.NoCountry) AS SchoolTotal FROM School '+; 'JOIN Country ON School.NoCountry=Country.Numero '+; 'WHERE School.Status=2 ORDER BY 2') RETURN loDMA.cHtml ENDIFThis SQL now works. It does't give any error. But, I only get one record. I am not sure what I have to adjust to get what I am looking for.