Decimal postion issue

M

Mitch_A

I setup a website for my softball team to use which includes a database that
keeps statistics.

Ive got everything working just fine but my queries for batting average show
the decimal positions incorrectly. I want them to show up as .389 not
..38943343243. Ive researched SQL for weeks now and I can find the
NUMERIC(4,3) statement but I cant seem to get it into the working query.
Would the ROUND function work?

Here is the query

SELECT sum(Hits)/(sum(ABs)-sum(Walks))
FROM Results

Can someone PLEASE show me where it goes?

TIA

Mitch
 
S

Stefan B Rusynko

Try

SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results

Then display is as
<% =Round(BatAvg,3) %>

Or better still use
SELECT sum(Hits) AS AllHits, (sum(ABs) AS AtBats ,sum(Walks) as AtWalks FROM Results

<% BatAvg=Round(AllHits/(AtBats-AtWal),3) %>

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I setup a website for my softball team to use which includes a database that
| keeps statistics.
|
| Ive got everything working just fine but my queries for batting average show
| the decimal positions incorrectly. I want them to show up as .389 not
| .38943343243. Ive researched SQL for weeks now and I can find the
| NUMERIC(4,3) statement but I cant seem to get it into the working query.
| Would the ROUND function work?
|
| Here is the query
|
| SELECT sum(Hits)/(sum(ABs)-sum(Walks))
| FROM Results
|
| Can someone PLEASE show me where it goes?
|
| TIA
|
| Mitch
|
|
 
M

Mitch_A

Inserted Snips:


This part worked in the query and the results show but still with an
incorrect decimal position.
SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results


This part Im not really sure where I should put it? Can you explain in a
Then display is as
<% =Round(BatAvg,3) %>

I tried this but the query failed no matter how I entered it.
Or better still use
SELECT sum(Hits) AS AllHits, (sum(ABs) AS AtBats ,sum(Walks) as AtWalks
FROM Results

As before Im not real sure where this goes even had the query worked.
<% BatAvg=Round(AllHits/(AtBats-AtWal),3) %>


Thanks you very much for any help past and future!

Mitch
 
S

Stefan B Rusynko

My code samples were for hand coded ASP, not for use w/ the DB results wizard

If you have used the query
SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results

Find in the displayed DBRW the field by FP DBRW using : BatAvg
- probably as something like: =FP_FieldVal(fp_rs,"BatAvg")
and wrap it in the Round Function as
=Round(FP_FieldVal(fp_rs,"BatAvg"),3)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Inserted Snips:
|
|
| This part worked in the query and the results show but still with an
| incorrect decimal position.
|
| > SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results
| >
|
|
| This part Im not really sure where I should put it? Can you explain in a
| bit more detail? I did try to replace the <<Express101>> in the DB results
| but it didnt work. Should I use the "Use HTML" option?
|
| > Then display is as
| > <% =Round(BatAvg,3) %>
| >
|
| I tried this but the query failed no matter how I entered it.
|
| > Or better still use
| > SELECT sum(Hits) AS AllHits, (sum(ABs) AS AtBats ,sum(Walks) as AtWalks
| > FROM Results
| >
|
| As before Im not real sure where this goes even had the query worked.
|
| > <% BatAvg=Round(AllHits/(AtBats-AtWal),3) %>
|
|
| Thanks you very much for any help past and future!
|
| Mitch
|
|
 
M

Mitch_A

I think Im getting really close thanks.

I found the entry in the DBRW <%=FP_FieldVal(fp_rs,"BatAvg")%

I can easily change it but when I save the page a dialog box pops up telling
me "The contents of a FrontPage component have been modified. These
contents will be overwritten when you save this page". I click OK and my
changes are reverted back as before. Any ideas? Ive checked the
attributes and its not read only.

Thanks again.

Mitch
 
K

Kathleen Anderson [MVP - FrontPage]

Can you make the change in the gray-colored code? If so, do that, and save
the change while you're still in Code View.

--

~ Kathleen Anderson
Microsoft MVP - FrontPage
Spider Web Woman Designs
web: http://www.spiderwebwoman.com/resources/
FrontPage Support: http://www.frontpagemvps.com/




Mitch_A said:
I think Im getting really close thanks.

I found the entry in the DBRW <%=FP_FieldVal(fp_rs,"BatAvg")%

I can easily change it but when I save the page a dialog box pops up
telling me "The contents of a FrontPage component have been modified.
These contents will be overwritten when you save this page". I click OK
and my changes are reverted back as before. Any ideas? Ive checked the
attributes and its not read only.

Thanks again.

Mitch
Stefan B Rusynko said:
My code samples were for hand coded ASP, not for use w/ the DB results
wizard

If you have used the query
SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results

Find in the displayed DBRW the field by FP DBRW using : BatAvg
- probably as something like: =FP_FieldVal(fp_rs,"BatAvg")
and wrap it in the Round Function as
=Round(FP_FieldVal(fp_rs,"BatAvg"),3)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Inserted Snips:
|
|
| This part worked in the query and the results show but still with an
| incorrect decimal position.
|
| > SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results
| >
|
|
| This part Im not really sure where I should put it? Can you explain in
a
| bit more detail? I did try to replace the <<Express101>> in the DB
results
| but it didnt work. Should I use the "Use HTML" option?
|
| > Then display is as
| > <% =Round(BatAvg,3) %>
| >
|
| I tried this but the query failed no matter how I entered it.
|
| > Or better still use
| > SELECT sum(Hits) AS AllHits, (sum(ABs) AS AtBats ,sum(Walks) as
AtWalks
| > FROM Results
| >
|
| As before Im not real sure where this goes even had the query worked.
|
| > <% BatAvg=Round(AllHits/(AtBats-AtWal),3) %>
|
|
| Thanks you very much for any help past and future!
|
| Mitch
|
|
 
M

Mitch_A

This is the section from the HTML view.
%=FP_FieldVal(fp_rs,"BatAvg")% and its Maroon. I change it to
%=Round(FP_FieldVal(fp_rs,"BatAvg"),3)
It just will not accept this change and reverts back.

Mitch


Kathleen Anderson said:
Can you make the change in the gray-colored code? If so, do that, and save
the change while you're still in Code View.

--

~ Kathleen Anderson
Microsoft MVP - FrontPage
Spider Web Woman Designs
web: http://www.spiderwebwoman.com/resources/
FrontPage Support: http://www.frontpagemvps.com/




Mitch_A said:
I think Im getting really close thanks.

I found the entry in the DBRW <%=FP_FieldVal(fp_rs,"BatAvg")%

I can easily change it but when I save the page a dialog box pops up
telling me "The contents of a FrontPage component have been modified.
These contents will be overwritten when you save this page". I click OK
and my changes are reverted back as before. Any ideas? Ive checked the
attributes and its not read only.

Thanks again.

Mitch
Stefan B Rusynko said:
My code samples were for hand coded ASP, not for use w/ the DB results
wizard

If you have used the query
SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results

Find in the displayed DBRW the field by FP DBRW using : BatAvg
- probably as something like: =FP_FieldVal(fp_rs,"BatAvg")
and wrap it in the Round Function as
=Round(FP_FieldVal(fp_rs,"BatAvg"),3)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Inserted Snips:
|
|
| This part worked in the query and the results show but still with an
| incorrect decimal position.
|
| > SELECT sum(Hits)/(sum(ABs)-sum(Walks)) AS BatAvg FROM Results
| >
|
|
| This part Im not really sure where I should put it? Can you explain
in a
| bit more detail? I did try to replace the <<Express101>> in the DB
results
| but it didnt work. Should I use the "Use HTML" option?
|
| > Then display is as
| > <% =Round(BatAvg,3) %>
| >
|
| I tried this but the query failed no matter how I entered it.
|
| > Or better still use
| > SELECT sum(Hits) AS AllHits, (sum(ABs) AS AtBats ,sum(Walks) as
AtWalks
| > FROM Results
| >
|
| As before Im not real sure where this goes even had the query worked.
|
| > <% BatAvg=Round(AllHits/(AtBats-AtWal),3) %>
|
|
| Thanks you very much for any help past and future!
|
| Mitch
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top