我正在对 Gerrit 进行一些扩展。我有以下查询来从 gerrit DB 中获取特定 ACCOUNT_ID 的 TOTAL COMMITS、TOTOAL REVIEW COMMENTS...等。
with
changeids as
(select change_id from PATCH_SETS where UPLOADER_ACCOUNT_ID=1001961),
patchcommentstoothers as
(select count(*) c from patch_comments where AUTHOR_ID!=1001961 AND Change_id in (select change_id from changeids)),
ownerchanges as
(select count(*) c from changes where owner_account_ID=1001961 and OPEN='Y'),
changemessages as
(select count(*) c from change_messages where AUTHOR_ID=1001961 and change_id not in (select change_id from changeids))
select pcto.c TOT_PATCH_COMMENTS, oc.c TOT_CHANGES, cm.c TOT_CHANGE_MESSAGES
from patchcommentstoothers pcto, ownerchanges oc, changemessages cm;
现在通过上面的查询,我可以获得一个用户的三个计数。我想对所有 ACCOUNT_ID 运行上述查询。像为每个账户运行这个查询(不仅仅是这里的 1001961)并一次性取回所有账户的所有记录。
ACCOUNT 表具有以下列:
"REGISTERED_ON" TIMESTAMP (6) NOT NULL ENABLE,
"FULL_NAME" VARCHAR2(255 BYTE),
"PREFERRED_EMAIL" VARCHAR2(255 BYTE),
"CONTACT_FILED_ON" TIMESTAMP (6),
"MAXIMUM_PAGE_SIZE" NUMBER(6,0) DEFAULT 0,
"SHOW_SITE_HEADER" CHAR(1 BYTE) DEFAULT 'N',
"USE_FLASH_CLIPBOARD" CHAR(1 BYTE) DEFAULT 'N',
"DOWNLOAD_URL" VARCHAR2(20 BYTE),
"DOWNLOAD_COMMAND" VARCHAR2(20 BYTE),
"COPY_SELF_ON_EMAIL" CHAR(1 BYTE) DEFAULT 'N',
"DATE_FORMAT" VARCHAR2(10 BYTE),
"TIME_FORMAT" VARCHAR2(10 BYTE),
"INACTIVE" CHAR(1 BYTE) DEFAULT 'N',
"ACCOUNT_ID" NUMBER(11,0) DEFAULT 0
我宁愿不使用程序。
PS - 我很讨厌 Oracle SQL。