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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:48:45+00:00 2026-05-31T12:48:45+00:00

Belows are the xml data stored in a field call xmldoc with data type

  • 0

Belows are the xml data stored in a field call xmldoc with data type XMLTYPE and the pattern are stored in each record.

The first row(record) of the xmldoc field should be:

<cdata>
<r> <year>2009</year>
<month>Jan</month>
<day>1</day>
<data>1180</data>
</r>
</cdata>

and the second row of the xmldoc field should be:

<cdata>
<r>
<year>2009</year>
<month>Jan</month>
<day>2</day>
<data>1280</data>
</r>
</cdata>

and the belowed xml datas are also modified into the upper example (each data stored in a row record in xmldoc field and embedded a ‘cdata’ root element.)

<r>
<year>2009</year>
<month>Jan</month>
<day>3</day>
<data>1380</data>
</r>
<r>
<year>2009</year>
<month>Feb</month>
<day>1</day>
<data>2180</data>
</r>
<r>
<year>2009</year>
<month>Feb</month>
<day>2</day>
<data>2280</data>
</r>
<r>
<year>2009</year>
<month>Feb</month>
<day>3</day>
<data>2380</data>
</r>
<r>
<year>2010</year>
<month>Jan</month>
<day>1</day>
<data>1181</data>
</r>
<r>
<year>2010</year>
<month>Jan</month>
<day>2</day>
<data>1281</data>
</r>
<r>
<year>2010</year>
<month>Jan</month>
<day>3</day>
<data>1381</data>
</r>
<r>
<year>2010</year>
<month>Feb</month>
<day>1</day>
<data>2181</data>
</r>
<r>
<year>2010</year>
<month>Feb</month>
<day>2</day>
<data>2281</data>
</r>
<r>
<year>2010</year>
<month>Feb</month>
<day>3</day>
<data>2381</data>
</r>

now, i use this sql:

SELECT X.year, x.month, sum(x.data) as sumMonth
FROM xmltest, 
XMLTABLE ('$d/cdata/r' passing xmldoc as "d" 
   COLUMNS 
  year integer path 'year',
  month varchar(3) path 'month',
  day varchar(2) path 'day',
  data float path 'data'
  ) AS X
group by x.year, x.month

order by x.year, x.month

i can get the sum of ‘data’ by each month in each year from this sql and the question i would like to know is how to display the sum of each year after the column sumMonth and just modify this sql but not use two or more sql to get the aggregation of month and year in same time.

the output maybe like this:

year month  sumMonth sumYear
2009  Jan    3840     10680
2009  Feb    6840     10680
2010  Jan    3843     10686
2010  Feb    6843     10686

thanks everyone gave me the answer 🙂

  • 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-05-31T12:48:46+00:00Added an answer on May 31, 2026 at 12:48 pm

    You could use an analytic function:

    SELECT v.YEAR, v.MONTH, v.sumMonth, 
           SUM(v.sumMonth) over(PARTITION BY v.YEAR) sumYear
      FROM (SELECT X.YEAR, x.MONTH, SUM(x.data) AS sumMonth
               FROM xmltest,
                    XMLTABLE('$d/cdata/r' passing xmldoc AS "d" 
                      COLUMNS YEAR INTEGER path 'year',
                              MONTH VARCHAR(3) path 'month',
                              DAY VARCHAR(2) path 'day',
                              data FLOAT path 'data') AS X
              GROUP BY x.YEAR, x.MONTH) v
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have hierarchical data stored in an XML file. There are multiple companies, each
I have GPS data stored as as .tcx file. This is a xml file
I have a large amount of data stored in an XML file, 173 MB
Below is my XML file, which is used to stored the data - <Locations>
I have a data stored in a xml column and need a comma-separated list
How to retrieve the value of type in the below XML <info><category>Flip</category><info>2</info><type>Tree</type></info>
I have a stored procedure that takes an XML parameter and inserts the Entity
I have xml files been imported onto an FTP server. This is stored in
The goal is to produce the following XML with JAXB <foo> <bar>string data</bar> <bar>binary
My question is: In JUnit, How do I setup xml data for my System

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.