SQL Language (MOSC)

MOSC Banner

group by top n values

in SQL Language (MOSC) 2 commentsAnswered ✓
There are plenty solutions how to group by top n values but I look for one step more. I also want to sum all other groups and add it as n+1 value.
To clarify simple example below:

select letter, count(*) from some_text group by letter

A 100
B 120
C 3
D 280
E 2
F 1
G 300

above is result of simple query which groups by "Letters" . What I would like to do is to present top 4 values and add a fifth value something like "others_letters"

A 100
B 120
D 280
G 300
other_letters 6


any hints ?

regards
K.



Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center