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 7993581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:53:40+00:00 2026-06-04T13:53:40+00:00

Currently when I issue this SQL, it gets the distinct username. I have some

  • 0

Currently when I issue this SQL, it gets the distinct username.

I have some distinct usernames, which represent groups, e.g. GRP_BSN.

I would like to group all the other usernames (which happens to be numeric) into a group e.g. GRP_OTHERS

select username, count(*)
from host
where seq between 0 and 2000
group by username;

63149   1
63732   1
64110   2
70987   12
76841   4
GRP_BSN 226
GRP_ASN 243
GRP_DSC 93

Can I achieve something like this:

GRP_OTHERS 20
GRP_BSN 226
GRP_ASN 243
GRP_DSC 93

EDIT: Modified query from answer

select username, count(*)
from host
  where created_dt 
  -- date selection
  between to_date('2012-may-23 00:00:00', 'yyyy-mon-dd hh24:mi:ss') 
  and to_date('2012-may-23 23:59:59', 'yyyy-mon-dd hh24:mi:ss')
GROUP BY CASE
             WHEN REGEXP_LIKE(username, '^\d+$') THEN 'GRP_OTHERS'
                                                 ELSE username
         END;
  • 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-04T13:53:42+00:00Added an answer on June 4, 2026 at 1:53 pm

    @bfavaretto is nice (+1 to him), but if you don’t know about username prefix or they are different you can go with something like:

    GROUP BY CASE
                 WHEN REGEXP_LIKE(username, '^\d+$') THEN 'GRP_OTHERS'
                                                     ELSE username
             END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently learning Hibernate, and I've stumbled into this issue: I have defined 3
I'm currently using Entity Framework and am running into this issue: The relationship between
I'm currently using this jQuery validate plugin and having an issue in IE where
I'm currently struggling with this Collection was modified; enumeration operation may not execute issue.
Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
I currently have a issue with firefox, where all other browser behave in the
I'm currently having an issue storing mouse coordinates into an array in which a
I have a sticky SQL issue and I'm not the best with SQL... I
I currently have 2 tables, one is idtracker which has around 30,000 rows and
I am having this kind of mysterious issue here. I am currently using Entity

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.