如何确保我在父记录上获得唯一性?我想每天计算 mopid + 用户的数量。我怎样才能做到这一点?到目前为止,这是我的代码,我只是不太相信它不会在 mopid + user + day 上给我独特性。
SELECT TO_CHAR(MOPNOTES.MOPNOTEDATE, 'YYYY-MM-DD') DayWorked, MOPNOTES.MOPNOTEUSER, MOPNOTES.mopid, COUNT(*) AS DAILY
FROM MOPUSER.MOPACTIVITY
INNER JOIN MOPUSER.MOPNOTES
ON MOPACTIVITY.MOPID=MOPNOTES.MOPID
WHERE MOPNOTES.MOPNOTEDATE > TO_DATE('01-JUL-13', 'DD-MON-YY') AND MOPNOTES.MOPNOTEDATE< TO_DATE('01-AUG-13', 'DD-MON-YY')
AND MOPACTIVITY.MOPSERVICEIMPACTED <> 'VOICE'
AND MOPACTIVITY.MOPSERVICEIMPACTED <> 'PWR/ENV'
AND (MOPNOTES.MOPNOTEUSER LIKE '%Ramesh%'
OR MOPNOTES.MOPNOTEUSER LIKE '%Saravanan%'
OR MOPNOTES.MOPNOTEUSER LIKE '%Boominathan%'
OR MOPNOTES.MOPNOTEUSER LIKE '%Srinivasan%'
OR MOPNOTES.MOPNOTEUSER LIKE '%Sathya%')
GROUP BY TO_CHAR(MOPNOTES.MOPNOTEDATE, 'YYYY-MM-DD'),MOPNOTES.MOPNOTEUSER,MOPNOTES.MOPID
ORDER BY TO_CHAR(MOPNOTES.MOPNOTEDATE, 'YYYY-MM-DD'),MOPNOTES.MOPNOTEUSER,MOPNOTES.MOPID