Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7977699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:16:45+00:00 2026-06-04T09:16:45+00:00

I am working on a some extensions to Gerrit. I have the following query

  • 0

I am working on a some extensions to Gerrit. I have the following query to get the TOTAL COMMITS, TOTOAL REVIEW COMMENTS…etc for a particular ACCOUNT_ID from the gerrit DB.

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;

Now with the above query I can get the three counts for one user. I want to run the above query for all ACCOUNT_ID’s. Something like run this query for each account (not just for 1001961 here) and get back all the records in one go for all accounts.

ACCOUNT table has the following columns:

"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

I would prefer not to use procedures.

P.S. – I suck at Oracle SQL.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:16:47+00:00Added an answer on June 4, 2026 at 9:16 am
    with
      changeids
    as
    (
      select
        UPLOADER_ACCOUNT_ID,
        change_id
      from
        PATCH_SETS
      group by
        UPLOADER_ACCOUNT_ID,
        change_id
    ),
      patchcommentstoothers
    as
    (
      select
        changeids.UPLOADER_ACCOUNT_ID,
        count(*) c
      from
        changeids
      inner join
        patch_comments
          ON  changeids.UPLOADER_ACCOUNT_ID != patch_comments.AUTHOR_ID
          AND changeids.change_id            = patch_comments.change_id
      group by
        changeids.UPLOADER_ACCOUNT_ID 
    ),
      ownerchanges
    as
    (
      select
        owner_account_ID,
        count(*) c
      from
        changes
      where
        OPEN='Y'
      group by
        owner_account_ID
    ),
      changemessages
    as
    (
      select
        change_messages.AUTHOR_ID,
        count(*) c
      from
        change_messages
      left join
        changeids
          on  changeids.UPLOADER_ACCOUNT_ID = change_messages.AUTHOR_ID
          AND changeids.change_id           = change_messages.change_id
      where
        changeids.change_id IS NULL
      group by
        change_messages.AUTHOR_ID
    )
    
    select
      accounts.ACCOUNT_ID,
      pcto.c   TOT_PATCH_COMMENTS,
      oc.c     TOT_CHANGES,
      cm.c     TOT_CHANGE_MESSAGES
    from
      accounts
    LEFT JOIN
      patchcommentstoothers pcto
        ON accounts.ACCOUNT_ID = pcto.UPLOADER_ACCOUNT_ID
    LEFT JOIN
      ownerchanges          oc
        ON accounts.ACCOUNT_ID = oc.owner_account_ID
    LEFT JOIN
      changemessages        cm
        ON accounts.ACCOUNT_ID = cm.AUTHOR_ID
    ;
    

    The CTEs now calculate the values for every user.

    The final select assumes that you have a user table that lists all of your users.

    If you filter the final query by user, the CTEs will only calculate the results for the users in the final results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little sample application I was working on trying to get some
I`m working on some sql queries to get some data out of a table;
I have some working code with a crutch to add BOM marker to a
I have been writing some python extension modules with cython. The extensions I've written
I have been trying for some time now to get my Rails development environment
In a PHP project I'm working on we need to create some DAL extensions
I am working with some network simulator. After making some extensions to it, I
I'm working on some Firefox extensions and I'm trying to set up my vim
Working on some dynamic pages and specifically we have profile pages for users. However
I'm using the following code to trim the file extensions of some items .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.