>select doctor >do while !eof() > llcount = 0 > > SELECT count(distinct(UPPER(ALLTRIM(MYTABLE.caddress)))) as llCount > FROM MYTABLE WHERE MYTABLE.docid = doctor.docid > AND MYTABLE.cstatus <> "XXX" > AND BETWEEN(TTOD(MYTABLE.ddate), tDateFrom, tDateTo) > INTO CURSOR curDocTot > > select newtable > append blank > replace newtable.count with llCount > > skip in doctor > >enddo>
SELECT docid ; , count(distinct UPPER(ALLTRIM(caddress))) as count ; FROM MYTABLE ; WHERE cstatus <> "XXX" ; AND ddate BETWEEN m.tDateFrom AND m.tDateTo ; GROUP BY 1; INTO CURSOR newtable