Hie everybody,
I have a problem with the following,
I have a table with a row containing numbers with 2 decimal places.
I want to count the sum of these numbers but my valuw returned is far to
high. I think the SUM string doesn't look at the decimal place.
The same is with the AVG string
Here are the ones I tried :
set rs = db.execute("Sel ect SUM(ePrize) from tbleventinfo")
if rs.EOF = false then
aveprize = Formatnumber(rs .fields.item(0) ,2)
else
aveprize = 0
end if
set rs = Nothing
and
set rs = db.execute("Sel ect AVG(ePrize) from tbleventinfo")
if rs.EOF = false then
aveprize = Formatnumber(rs .fields.item(0) ,2)
else
aveprize = 0
end if
set rs = Nothing
Can anybody help me allong the way?!
Thanks in advance,
Willem-Jan Selen 6 4229
Ok here's a copy of my row
the result of the AVG string which I wrote down below is 2.810,29 the SUM
string produces the following 95.550,00 which is the exact total of the
average...
Hope any body can help ?
tblEventInfo ePrize
37,50
35,00
35,00
40,00
22,00
40,00
0,00
35,00
37,50
24,00
17,50
30,00
22,50
11,00
10,00
20,00
23,00
25,50
35,00
40,50
40,00
40,00
47,00
47,00
50,00
22,00
35,00
22,00
22,00
25,00
22,00
0
42,50
0
"Mark Schupp" <ms*****@ielear ning.com> wrote in message
news:ed******** ******@TK2MSFTN GP10.phx.gbl... show examples of your data and the results you are getting.
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com 714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message news:1058791405 .289835@cache2. .. Hie everybody,
I have a problem with the following,
I have a table with a row containing numbers with 2 decimal places.
I want to count the sum of these numbers but my valuw returned is far to high. I think the SUM string doesn't look at the decimal place.
The same is with the AVG string
Here are the ones I tried :
set rs = db.execute("Sel ect SUM(ePrize) from tbleventinfo") if rs.EOF = false then aveprize = Formatnumber(rs .fields.item(0) ,2) else aveprize = 0 end if set rs = Nothing
and
set rs = db.execute("Sel ect AVG(ePrize) from tbleventinfo") if rs.EOF = false then aveprize = Formatnumber(rs .fields.item(0) ,2) else aveprize = 0 end if set rs = Nothing Can anybody help me allong the way?!
Thanks in advance,
Willem-Jan Selen
Hmm - I'm not sure how it would handle the ',' in there - that's not a
decimal place - it's a comma.
Maybe you have to explicitly convert the field contents to a decimal(10,2)
etc. to get the correct sum and avg values?
Chris.
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message
news:1058808057 .405075@cache2. .. Ok here's a copy of my row the result of the AVG string which I wrote down below is 2.810,29 the SUM string produces the following 95.550,00 which is the exact total of the average...
Hope any body can help ?
tblEventInfo ePrize 37,50 35,00 35,00 40,00 22,00 40,00 0,00 35,00 37,50 24,00 17,50 30,00 22,50 11,00 10,00 20,00 23,00 25,50 35,00 40,50 40,00 40,00 47,00 47,00 50,00 22,00 35,00 22,00 22,00 25,00 22,00 0 42,50 0
"Mark Schupp" <ms*****@ielear ning.com> wrote in message news:ed******** ******@TK2MSFTN GP10.phx.gbl... show examples of your data and the results you are getting.
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com 714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message news:1058791405 .289835@cache2. .. Hie everybody,
I have a problem with the following,
I have a table with a row containing numbers with 2 decimal places.
I want to count the sum of these numbers but my valuw returned is far
to high. I think the SUM string doesn't look at the decimal place.
The same is with the AVG string
Here are the ones I tried :
set rs = db.execute("Sel ect SUM(ePrize) from tbleventinfo") if rs.EOF = false then aveprize = Formatnumber(rs .fields.item(0) ,2) else aveprize = 0 end if set rs = Nothing
and
set rs = db.execute("Sel ect AVG(ePrize) from tbleventinfo") if rs.EOF = false then aveprize = Formatnumber(rs .fields.item(0) ,2) else aveprize = 0 end if set rs = Nothing Can anybody help me allong the way?!
Thanks in advance,
Willem-Jan Selen
What is the datatype of the eprize column?
What DBMS are you using?
Is the locale numeric format on the DBMS server the same as the format on
the web-server?
What value do you get for aveprize?
What do you get if you leave out formatnumber and just display the raw
results?
If you execute "select count(eprize) from tblEventInfo" do you get the
expected number of rows?
--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com
714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message
news:1058808057 .405075@cache2. .. Ok here's a copy of my row the result of the AVG string which I wrote down below is 2.810,29 the SUM string produces the following 95.550,00 which is the exact total of the average...
Hope any body can help ?
tblEventInfo ePrize 37,50 35,00 35,00 40,00 22,00 40,00 0,00 35,00 37,50 24,00 17,50 30,00 22,50 11,00 10,00 20,00 23,00 25,50 35,00 40,50 40,00 40,00 47,00 47,00 50,00 22,00 35,00 22,00 22,00 25,00 22,00 0 42,50 0
"Mark Schupp" <ms*****@ielear ning.com> wrote in message news:ed******** ******@TK2MSFTN GP10.phx.gbl... show examples of your data and the results you are getting.
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com 714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message news:1058791405 .289835@cache2. .. Hie everybody,
I have a problem with the following,
I have a table with a row containing numbers with 2 decimal places.
I want to count the sum of these numbers but my valuw returned is far
to high. I think the SUM string doesn't look at the decimal place.
The same is with the AVG string
Here are the ones I tried :
set rs = db.execute("Sel ect SUM(ePrize) from tbleventinfo") if rs.EOF = false then aveprize = Formatnumber(rs .fields.item(0) ,2) else aveprize = 0 end if set rs = Nothing
and
set rs = db.execute("Sel ect AVG(ePrize) from tbleventinfo") if rs.EOF = false then aveprize = Formatnumber(rs .fields.item(0) ,2) else aveprize = 0 end if set rs = Nothing Can anybody help me allong the way?!
Thanks in advance,
Willem-Jan Selen
Alright I solved it with the following
Set rs = db.execute("Sel ect * from tblEventinfo where evalid = true")
prize = 0
if rs.EOF = false then
while not rs.EOF
wj = rs("eprize")
prize = prize + wj
rs.moveNext
wend
End If
set rs = Nothing
and displaying the final value as
Formatnumber(pr ize,2)
and the averge number by using
set rs = db.execute("Sel ect COUNT(eID) from tblEventInfo where evalid =
true")
if rs.EOF = false then
numOfparty = rs.fields.item( 0)
else
numOfparty = 0
end if
set rs = Nothing
then dispaying the average
aveprize = prize / numofparty
echo Formatnumber(av eprize2,2)
And I know PRICE is not spelled PRIZE but does it mather in all of the
coding?
Thanx for all the help,
Willem-Jan Selen
"Mark Schupp" <ms*****@ielear ning.com> wrote in message
news:eW******** *****@TK2MSFTNG P12.phx.gbl... What is the datatype of the eprize column? What DBMS are you using? Is the locale numeric format on the DBMS server the same as the format on the web-server?
What value do you get for aveprize? What do you get if you leave out formatnumber and just display the raw results?
If you execute "select count(eprize) from tblEventInfo" do you get the expected number of rows?
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com 714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message news:1058808057 .405075@cache2. .. Ok here's a copy of my row the result of the AVG string which I wrote down below is 2.810,29 the
SUM string produces the following 95.550,00 which is the exact total of the average...
Hope any body can help ?
tblEventInfo ePrize 37,50 35,00 35,00 40,00 22,00 40,00 0,00 35,00 37,50 24,00 17,50 30,00 22,50 11,00 10,00 20,00 23,00 25,50 35,00 40,50 40,00 40,00 47,00 47,00 50,00 22,00 35,00 22,00 22,00 25,00 22,00 0 42,50 0
"Mark Schupp" <ms*****@ielear ning.com> wrote in message news:ed******** ******@TK2MSFTN GP10.phx.gbl... show examples of your data and the results you are getting.
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com 714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message news:1058791405 .289835@cache2. .. > Hie everybody, > > I have a problem with the following, > > I have a table with a row containing numbers with 2 decimal places. > > I want to count the sum of these numbers but my valuw returned is
far to > high. I think the SUM string doesn't look at the decimal place. > > The same is with the AVG string > > Here are the ones I tried : > > set rs = db.execute("Sel ect SUM(ePrize) from tbleventinfo") > if rs.EOF = false then > aveprize = Formatnumber(rs .fields.item(0) ,2) > else > aveprize = 0 > end if > set rs = Nothing > > > and > > set rs = db.execute("Sel ect AVG(ePrize) from tbleventinfo") > if rs.EOF = false then > aveprize = Formatnumber(rs .fields.item(0) ,2) > else > aveprize = 0 > end if > set rs = Nothing > > > > Can anybody help me allong the way?! > > Thanks in advance, > > Willem-Jan Selen > >
You can do this in one single SQL statement but you will have to handle the
column datatype yourself in the SQL statement. your solution relies on the
fact that the system locale understands the numeric format.
Have a look at CONVERT and CAST in SQL Books Online?
Chris.
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message
news:1058825681 .293243@cache2. .. Alright I solved it with the following
Set rs = db.execute("Sel ect * from tblEventinfo where evalid = true") prize = 0 if rs.EOF = false then while not rs.EOF wj = rs("eprize") prize = prize + wj rs.moveNext wend End If set rs = Nothing and displaying the final value as Formatnumber(pr ize,2) and the averge number by using
set rs = db.execute("Sel ect COUNT(eID) from tblEventInfo where evalid
= true") if rs.EOF = false then numOfparty = rs.fields.item( 0) else numOfparty = 0 end if set rs = Nothing
then dispaying the average aveprize = prize / numofparty echo Formatnumber(av eprize2,2)
And I know PRICE is not spelled PRIZE but does it mather in all of the coding?
Thanx for all the help,
Willem-Jan Selen
"Mark Schupp" <ms*****@ielear ning.com> wrote in message news:eW******** *****@TK2MSFTNG P12.phx.gbl... What is the datatype of the eprize column? What DBMS are you using? Is the locale numeric format on the DBMS server the same as the format
on the web-server?
What value do you get for aveprize? What do you get if you leave out formatnumber and just display the raw results?
If you execute "select count(eprize) from tblEventInfo" do you get the expected number of rows?
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com 714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message news:1058808057 .405075@cache2. .. Ok here's a copy of my row the result of the AVG string which I wrote down below is 2.810,29 the SUM string produces the following 95.550,00 which is the exact total of
the average...
Hope any body can help ?
tblEventInfo ePrize 37,50 35,00 35,00 40,00 22,00 40,00 0,00 35,00 37,50 24,00 17,50 30,00 22,50 11,00 10,00 20,00 23,00 25,50 35,00 40,50 40,00 40,00 47,00 47,00 50,00 22,00 35,00 22,00 22,00 25,00 22,00 0 42,50 0
"Mark Schupp" <ms*****@ielear ning.com> wrote in message news:ed******** ******@TK2MSFTN GP10.phx.gbl... > show examples of your data and the results you are getting. > > -- > Mark Schupp > -- > Head of Development > Integrity eLearning > Online Learning Solutions Provider > ms*****@ielearn ing.com > http://www.ielearning.com > 714.637.9480 x17 > > > "Willem-Jan Selen" <ws****@hotmail .com> wrote in message > news:1058791405 .289835@cache2. .. > > Hie everybody, > > > > I have a problem with the following, > > > > I have a table with a row containing numbers with 2 decimal
places. > > > > I want to count the sum of these numbers but my valuw returned is
far to > > high. I think the SUM string doesn't look at the decimal place. > > > > The same is with the AVG string > > > > Here are the ones I tried : > > > > set rs = db.execute("Sel ect SUM(ePrize) from tbleventinfo") > > if rs.EOF = false then > > aveprize = Formatnumber(rs .fields.item(0) ,2) > > else > > aveprize = 0 > > end if > > set rs = Nothing > > > > > > and > > > > set rs = db.execute("Sel ect AVG(ePrize) from tbleventinfo") > > if rs.EOF = false then > > aveprize = Formatnumber(rs .fields.item(0) ,2) > > else > > aveprize = 0 > > end if > > set rs = Nothing > > > > > > > > Can anybody help me allong the way?! > > > > Thanks in advance, > > > > Willem-Jan Selen > > > > > >
Well, I guess that will work, but I wouldn't trust my DBMS to do anything
right if it didn't give me an accurate value for the SUM of a column!!!!
--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com
714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message
news:1058825681 .293243@cache2. .. Alright I solved it with the following
Set rs = db.execute("Sel ect * from tblEventinfo where evalid = true") prize = 0 if rs.EOF = false then while not rs.EOF wj = rs("eprize") prize = prize + wj rs.moveNext wend End If set rs = Nothing and displaying the final value as Formatnumber(pr ize,2) and the averge number by using
set rs = db.execute("Sel ect COUNT(eID) from tblEventInfo where evalid
= true") if rs.EOF = false then numOfparty = rs.fields.item( 0) else numOfparty = 0 end if set rs = Nothing
then dispaying the average aveprize = prize / numofparty echo Formatnumber(av eprize2,2)
And I know PRICE is not spelled PRIZE but does it mather in all of the coding?
Thanx for all the help,
Willem-Jan Selen
"Mark Schupp" <ms*****@ielear ning.com> wrote in message news:eW******** *****@TK2MSFTNG P12.phx.gbl... What is the datatype of the eprize column? What DBMS are you using? Is the locale numeric format on the DBMS server the same as the format
on the web-server?
What value do you get for aveprize? What do you get if you leave out formatnumber and just display the raw results?
If you execute "select count(eprize) from tblEventInfo" do you get the expected number of rows?
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider ms*****@ielearn ing.com http://www.ielearning.com 714.637.9480 x17
"Willem-Jan Selen" <ws****@hotmail .com> wrote in message news:1058808057 .405075@cache2. .. Ok here's a copy of my row the result of the AVG string which I wrote down below is 2.810,29 the SUM string produces the following 95.550,00 which is the exact total of
the average...
Hope any body can help ?
tblEventInfo ePrize 37,50 35,00 35,00 40,00 22,00 40,00 0,00 35,00 37,50 24,00 17,50 30,00 22,50 11,00 10,00 20,00 23,00 25,50 35,00 40,50 40,00 40,00 47,00 47,00 50,00 22,00 35,00 22,00 22,00 25,00 22,00 0 42,50 0
"Mark Schupp" <ms*****@ielear ning.com> wrote in message news:ed******** ******@TK2MSFTN GP10.phx.gbl... > show examples of your data and the results you are getting. > > -- > Mark Schupp > -- > Head of Development > Integrity eLearning > Online Learning Solutions Provider > ms*****@ielearn ing.com > http://www.ielearning.com > 714.637.9480 x17 > > > "Willem-Jan Selen" <ws****@hotmail .com> wrote in message > news:1058791405 .289835@cache2. .. > > Hie everybody, > > > > I have a problem with the following, > > > > I have a table with a row containing numbers with 2 decimal
places. > > > > I want to count the sum of these numbers but my valuw returned is
far to > > high. I think the SUM string doesn't look at the decimal place. > > > > The same is with the AVG string > > > > Here are the ones I tried : > > > > set rs = db.execute("Sel ect SUM(ePrize) from tbleventinfo") > > if rs.EOF = false then > > aveprize = Formatnumber(rs .fields.item(0) ,2) > > else > > aveprize = 0 > > end if > > set rs = Nothing > > > > > > and > > > > set rs = db.execute("Sel ect AVG(ePrize) from tbleventinfo") > > if rs.EOF = false then > > aveprize = Formatnumber(rs .fields.item(0) ,2) > > else > > aveprize = 0 > > end if > > set rs = Nothing > > > > > > > > Can anybody help me allong the way?! > > > > Thanks in advance, > > > > Willem-Jan Selen > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: netclectic |
last post by:
Hi folks, i've searched and searched and can't find any example of
what i'm trying to do. Essentially (i think) i need to add a new
operator to Number.
I'm using eval to evaluate expressions that can be entered by users,
these expressions are defined by another app so i can't change the
format of the expressions. I've managed to support the majority of
operators by supplying my own functions that wrap the equivalent Math
functions but...
|
by: jm |
last post by:
I am trying to use datepart to get the real name of the month like
"April" or "APR" not just "4." I could not find it in the
documentation. Sorry. Thank you.
|
by: Steve Peterson |
last post by:
Hi
I have an app where I have to deal with both Spanish & American formatting.
I have a string that represents a number that I need to convert to Int32
before I enter it in the database. The string can be any number, for
example, "1,355" (American style) or "1.355" (Spanish style) . I know could
use the Replace method and "strip" the number string of "." or the "," then
convert what is left to Int32.
But I thought maybe there is a...
|
by: james |
last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old
database file that has the date(s) stored in it as number of days.
An example is: 36,525 represents 01/01/1900. The starting point date is considered to be :
00/00/0000. I have looked thru Help and used Google and have not really found an answer.
I know that Leap Years need to be accounted for too.
Any...
|
by: Robert |
last post by:
How do you get an accurate count of the number of records returned from
a query when using linked tables.
I have an access 2003 database as a front end to another access 2003
database that contains only tables. I have linked the tables for the
front end to the back end database.
I am trying to set the recordsource of a form to a query established by
the user to narrow the scope but I don't want to display the form if
there are no...
| |
by: Ntl News Group |
last post by:
I have a text box that contains the number 1234, I want the value form
the text box to display in a second text box so I used:
=
The problems is that this displays 1234 and I want it to display 1,234
using a comma for the thousands and no decimal places.
I changed the format on the second text box to:
=Format(,”Standard”)
|
by: Wayne |
last post by:
I am charting data from a query that consists of a Date/Time field and
a Number field. The Date/Time field is the x scale on my chart.
Sometimes data is collected from different times during the one day.
I need to be able to see these times as different time points on the x
scale of my chart. To accomplish this I am using the following
statement as the row source for my chart: "SELECT
(Format(,"DDDDD HAMPM")),Max() AS FROM
GROUP BY...
|
by: Dixie |
last post by:
I am appending some new fields to a table in vba and when I append a number
field with is a byte, it does not inherit any format. I want it to be the
General Number format, but it is blank. I have tried to change the format
with the following code, but it does not work. What is wrong with this code
and how can I make that byte number field have the General Number format?
Call...
|
by: michaelw118 |
last post by:
Hi,
I hope someone can give me some solutions to these problems I faced.
I imported some data to Excel. Then in Access, I table-linked to this file. I have two fields which in Excel is in number format but in Access, these fields property is text and the values in these fields become "#Num!". Others number format fields were okay, only these two fields (or particular columns?).
But if I linked directly to the datasource, it seems the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |