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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:55:58+00:00 2026-06-15T22:55:58+00:00

I have two tables: Table1 and Table2 . Table1 has columns RECORDID , DATASOURCETYPE

  • 0

I have two tables: Table1 and Table2. Table1 has columns RECORDID, DATASOURCETYPE and STRINGCLOB, whereas Table2 has columns RECORDID, TIMESTAMP and CLICKTYPE. I have written a query to find the clob XML string ‘book’ from the STRINGCLOB column, provided that it matches a given DATASOURCETYPE, as follows:

SELECT SUBSTR(stringclob, instr(stringclob, 'type>')+5
                        , instr(stringclob,'</type') 
                             - instr(stringclob, 'type>')-5
             ) r_type from Table1
 where DataSourceType = 'Source1'
   AND SUBSTR(stringclob, instr(stringclob,'type>')+5
                        , instr(stringclob, '</type')
                              - instr(stringclob, 'type>')-5
             )
     like '%book%'

Now, I would like to find and count all occurrences of ‘%book%’ string from the STRINGCLOB colum (Table1) that were recorded in the last month (something like AND TIMESTAMP > '01-Nov-12' AND TIMESTAMP < '01-Dec-12') and of CLICKTYPE <> 'Type1'. I am struggling with querying data from two distinct tables, any idea?

Thanks indeed,

I.

  • 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-15T22:55:59+00:00Added an answer on June 15, 2026 at 10:55 pm

    This is how you get the count of the record_type having value as book.

    WITH t
           AS (SELECT   '<?xml version="1.0" encoding="UTF-8"?>
                           <record>
                            <record_number>12345</record_number>
                             <record_type> book </record_type>
                           </record>'
                           STRINGCLOB
                 FROM   DUAL
               UNION ALL
               SELECT   '<?xml version="1.0" encoding="UTF-8"?>
                              <record>
                                <record_number>6789</record_number>
                                <record_type> book </record_type>
                             </record>'
                           STRINGCLOB
                 FROM   DUAL)
    SELECT   COUNT (1) total
      FROM   t
     WHERE   xmltype (t.STRINGCLOB).EXTRACT ('//record_type/text()') LIKE '%book%';
    

    total

    2

    Now,if you want to join with the table 2,based on record_id

     SELECT   COUNT (1) total
       FROM   table1 t1, table2 t2
      WHERE   xmltype (t1.STRINGCLOB).EXTRACT ('//record_type/text()') LIKE
                '%book%'
             AND t1.record_id = t2.record_id
             AND t1.DataSourceType = 'Source1'
             AND (TRUNC (t2.timestamp) > '01-Nov-12'
                  AND TRUNC (t2.timestamp) < '01-Dec-12')
             AND t2.clicktype <> 'Type1'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables - table1 and table2 table1 has 14 columns and table2
I have two tables: table1, table2. Table1 has 10 columns, table2 has 2 columns.
I have two tables table1 and table2 table1 has the columns: id name value
I have two tables table1 and table2. Both tables has multiple columns. table1: serialno
I have a database with two tables (Table1 and Table2). Table1 has one column
Suppose I have two tables in SQL where table1 has columns - id, name,
So I have two tables, Table1 and Table2. Table one has an integer that
I have two tables. Table1 is our main table of data and Table2 has
I have two tables; Leads, Territories and Referrers. Lead has columns: ID, Name, TerritoryId
I have two tables: a 'userlist' that has a 'grade' and 'userID' columns, and

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.