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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:41:07+00:00 2026-06-01T01:41:07+00:00

I have a table which have schema like this id name 1 jack 2

  • 0

I have a table which have schema like this

id name

1 jack
2 jack of eden
3 eden of uk
4 m of s

I want to execute a query which gives me count of words like this

count word
2 jack
2 eden
3 of

this means jack has been here 2 times, eden 2 times and of has been 3 times.

Hope you got the question, m trying too but not getting the right query or approach to it

thnx

  • 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-01T01:41:08+00:00Added an answer on June 1, 2026 at 1:41 am

    Assuming your table is named temp (probably not – change it to the right name of your table)

    I used a subquery for finding all the words in your table:

    select distinct regexp_substr(t.name, '[^ ]+',1,level) word , t.name, t.id
         from temp t
         connect by level <= regexp_count(t.name, ' ') + 1
    

    this query splits all the words from all records. I aliased it words.
    Then I joined it with your table (in the query it’s called temp) and counted the number of occurences in every record.

    select words.word, count(regexp_count(tt.name, words.word))
    from(
    select distinct regexp_substr(t.name, '[^ ]+',1,level) word , t.name, t.id
     from temp t
     connect by level <= regexp_count(t.name, ' ') + 1) words, temp tt
     where words.id= tt.id
     group by words.word
    

    You can also add:

    having count(regexp_count(tt.name, words.word)) > 1
    

    update: for better performance we can replace the inner subquery with the results of a pipelined function:
    first, create a schema type and a table of it:

    create or replace type t is object(word varchar2(100), pk number);
    /
    create or replace type t_tab as table of t;
    /
    

    then create the function:

    create or replace function split_string(del in varchar2) return t_tab
      pipelined is
    
      word    varchar2(4000);
      str_t   varchar2(4000) ;
      v_del_i number;
      iid     number;
    
      cursor c is
        select * from temp; -- change  to your table
    
    begin
    
      for r in c loop
        str_t := r.name;
        iid   := r.id;
    
        while str_t is not null loop
    
          v_del_i := instr(str_t, del, 1, 1);
    
          if v_del_i = 0 then
            word  := str_t;
            str_t := '';
          else
            word  := substr(str_t, 1, v_del_i - 1);
            str_t := substr(str_t, v_del_i + 1);
          end if;
    
          pipe row(t(word, iid));
    
        end loop;
    
      end loop;
    
      return;
    end split_string;
    

    now the query should look like:

    select words.word, count(regexp_count(tt.name, words.word))
    from(
    select word, pk as id from table(split_string(' '))) words, temp tt
     where words.id= tt.id
     group by words.word
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table one which looks like this. And I want to get data
I have a table which is full of arbitrarily formatted phone numbers, like this
I have this existing schema where a schedule table looks like this (very simplified).
I have a table in a Rails application which (in schema.rb) looks like: create_table
I have a table schema which is essentially a bunch of transaction info with
I have this array which gets the last table from a database. However the
I have a table schema which has some meta field data which I need
I have 3 tables which look like this: Location Node Sektor ----- ------- -------
I have table which contains double values stored in mysql database ...I need to
I have a table which is referenced by foreign keys on many other tables.

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.