473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XQuery problem - fn:sum

Hi All,

I hope someone could help; I need to query bunch of files in certain
collection in certain period of time and generate the result;

1. All files are stored in //Bookkeeping collection

2. XML file Syntax:

<?xml version="1.0" encoding="UTF-8"?>
<bookkeeping date="20050128">
<Cash>
<record billed="40" category="Fee" drid="2" index="1" pid="15" qty="1"
received="20" unitprice="">
<desc>Adjust 40</desc>
<bdate>20050130</bdate>
</record>
<record billed="40" category="Fee" drid="2" index="1" pid="15" qty="1"
received="20" unitprice="">
<desc>OST: Adjust 40</desc>
<bdate>20050130</bdate>
</record>
</Cash>
<VISA/>
<Debit/>
<Master/>
<AMEX/>
<Cheque/>
</bookkeeping>

3. My query:

for $b in //bookkeeping
let $m := $b/VISA/record/@billed
let $n := $b/VISA/record/@received
where $b/@date[contains(., '200501')] and $b/VISA/record/@billed > '0'
return
<VISA date="{$b/@date}" billed="{sum($m)}" received="{sum($n)}"/>

4. Current result:

<VISA date="20050112" billed="128.0" received="128.0"/>
<VISA date="20050106" billed="400.0" received="400.0"/>
<VISA date="20050119" billed="60.0" received="60.0"/>
<VISA date="20050125" billed="256.0" received="256.0"/>
<VISA date="20050126" billed="100.0" received="100.0"/>
<VISA date="20050127" billed="60.0" received="60.0"/>
<VISA date="20050131" billed="40.0" received="40.0"/>
<VISA date="20050130" billed="115.0" received="115.0"/>

------------------------------------------------------------------
What I need is:

<VISA billed="3400" received="3400"> - the summary of the above
results;

MANY THANKS,

Sava

Jul 20 '05 #1
0 954

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Karl Pech | last post by:
Hi, I got a task there I have to compute pi using the Method above. So I wrote the following program: --- import random import math
44
by: Mikito Harakiri | last post by:
This is a continuation of the old theme, now featuring xml. <tree> <node id=0 parent_id=null label='A'> <node id=1 parent_id=0 label='B'> <node id=2 parent_id=0 label='C'> ... </tree>
6
by: danmcleran | last post by:
I'm not seeing much benefit from psyco (only 5-10% faster). Maybe this example is too trivial? Can someone give me some pointers as to what kind of code would see a dramatic benefit? Here's the...
10
by: geekerbox | last post by:
Hi, I'm quite new to C++ and I found the other day something I didn't understand. One of the arguments of a function was "..." (without the quotes). What does it mean? Thanks for your help.
4
by: Suma | last post by:
I dont know xquery , so i was thinking someone in the forum will help me out with this easy question Suppose I have an instance document given below <Root> <Author Name='Alice' NumberOfBooks =...
1
by: inarobis | last post by:
Hello, I am newbie in Xquery and i would like to do a simple group by date and ID. so a piece of my xml file. <Authors> <Author> <ID>1</ID> <Date>30.07.2000</Date>
103
by: aboxylica | last post by:
hey! I have a program that takes two input files(one in the matrix form) and one in the sequence form.Now my problem is that i have to give the matrix file(containing many matrices) and sequence...
10
by: bluemountain | last post by:
Hi there, Iam new to python forms and programming too I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2,...
60
by: Bill Cunningham | last post by:
I have a row of values like such, placed in a text file by fprintf. 10.50 10.25 10.00 10.75 11.00 What I want to do to the above colum is add a new column right beside it which is a total...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.