473,394 Members | 2,020 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,394 software developers and data experts.

Grouping totalling maybe an array?

Hi there,

I have an estimate file that gets printed for customers. The file
consists of a verbiage line like ROOF then the estimated items follow
under that "V" then another category like FIRST FLOOR and more estimated
items, etc. I'd like to be able to get a subtotal between the verbiage
lines but I have no idea how to accomplish this. The verbiage lines
have a line code of "V" and the corresponding items have a line code of
"N" under each "V". So I would want to add up all of the "N" item costs
under each "V". Is this possible? Many thanks in advance. Here's an
example...

V FIRST FLOOR
N NAILS 56.00
N BOARDS 175.00

(subtotal of FIRST FLOOR 231.00)
V ROOF
N SHINGLES 3000.00
N PLYWOOD 500.00

(subtotal of ROOF 3500.00)

etc.
P.S. Please be nice, I'm not a brain like you guys out there.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #1
6 1251
Where is the data coming from? A database? If so, what version, and what
does your current query look like?

Ray at work

"Debbie Davis" <dd@clickfocal.com> wrote in message
news:Ol**************@TK2MSFTNGP14.phx.gbl...
Hi there,

I have an estimate file that gets printed for customers. The file
consists of a verbiage line like ROOF then the estimated items follow
under that "V" then another category like FIRST FLOOR and more estimated
items, etc. I'd like to be able to get a subtotal between the verbiage
lines but I have no idea how to accomplish this. The verbiage lines
have a line code of "V" and the corresponding items have a line code of
"N" under each "V". So I would want to add up all of the "N" item costs
under each "V". Is this possible? Many thanks in advance. Here's an
example...

V FIRST FLOOR
N NAILS 56.00
N BOARDS 175.00

(subtotal of FIRST FLOOR 231.00)
V ROOF
N SHINGLES 3000.00
N PLYWOOD 500.00

(subtotal of ROOF 3500.00)

etc.
P.S. Please be nice, I'm not a brain like you guys out there.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #2
My apologies Ray. It's a SQL 2000 database, no queries yet!! I really
don't know where to start. Thanks again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
Alright, what do your tables look like in your database? Can you mimic the
layout with some sample data here, i.e.

Table1:

ID Title Price
1 Nails 39
2 Hammer 19
3 Level 52

Customers:
ID......

Help us "see" what you have to work with as a datasource.

Ray at work

"Debbie Davis" <dd@clickfocal.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
My apologies Ray. It's a SQL 2000 database, no queries yet!! I really
don't know where to start. Thanks again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #4
Is this an existing application? Or are you designing this from scratch...

Jeff
"Debbie Davis" <dd@clickfocal.com> wrote in message
news:#4**************@TK2MSFTNGP10.phx.gbl...
My apologies Ray. It's a SQL 2000 database, no queries yet!! I really
don't know where to start. Thanks again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #5

Table 1 (there's only one):

LN (identity) 1
estno 2968
lc V
description FIRST FLOOR
pcs 0
price 0

LN (identity) 2
estno 2968
lc N
description nails
pcs 1000
price 50

LN (identity) 3
estno 2968
lc N
description 1 x 2 x 8 boards
pcs 1000
price 25000

LN (identity) 4
estno 2968
lc V
description SECOND FLOOR
pcs 0
price 0

LN (identity) 5
estno 2968
lc N
description plywood
pcs 500
price 13000

LN (identity) 6
estno 2968
lc N
description hardiplank
pcs 100
price 350

and there could be as many as 20 entries (N lines) under each V code.
This is an old unix system and my boss wants it converted as closely as
possible. I've managed to convert the look and feel and database as
closely as possible and developed a data entry page to enter the
estimate, but the user will print a printer friendly estimate for the
customer and I need to subtotal the N codes under the V headings. So
the V lines are like headings and the N lines are items under each
heading.

FIRST FLOOR
nails 100 50
boards 1000 25000
subtotal 25050

SECOND FLOOR
plywood 13000
hardiplank 350
subtotal 13350

I hope that helps. Many thanks for your time.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #6

Hi Ray, I think I've got it. Here's what I've done and it's not very
pretty but it's working for me:

set rsPB=objConn.execute("SELECT SUM(extension) as ordertotal,SUM(pcs)
as totalitems,item_no,lc,description FROM est2 where (estno=2968) GROUP
BY item_no,LN,lc,description, line_no ORDER BY line_no")

if not rsPB.eof then
Response.Write "<hr>estimate for 2968"
Response.Write "<table border=1
width='100%'>"'<tr><th>Product<th>Cost"

oldCat=""
theCat=""
catTotal=0

do while not rsPB.eof
theCat=rsPB("lc")
theProduct=rsPB("item_no")
totalSale=rsPB("ordertotal")

if oldCat<>theCat then
if catTotal>0 then
response.write "<tr><td colspan=3 align=right><font
color=red>Total for category:<td align=right>" &
formatnumber(catTotal,2) & "<td align=right></font>" &
formatnumber(catTotal-catCost,2)
end if
Response.Write "<tr><td colspan=5><strong><u>" &
rsPB("description") & "</u></strong>"
catTotal=totalSale
catCost=totalCost
oldCat=theCat
else
catTotal=catTotal + totalSale
catCost=catCost + totalCost
end if

cname=rsPB("item_no")
totalitems=rsPB("totalitems")
if totalitems>0 then
totalitems=totalitems
else
totalitems=0
end if
ordertotal=rsPB("ordertotal")
if ordertotal>0 then
ordertotal=ordertotal
else
ordertotal=0
end if
oldCat=theCat
rsPB.movenext
loop
response.write "<tr><td colspan=3 align=right><font color=red>Total
for category:<td align=right>" & formatnumber(catTotal,2) & "<td
align=right></font>" & formatnumber(catTotal-catCost,2)
Response.Write "</table>"
end if

I'm sure there's lots of room for improvement. Many thanks for your
ideas!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #7

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

Similar topics

3
by: Kevin Brown | last post by:
Is there anyway to generate this type of resulting HTML table from this XML using XSLT? Basically I need to be able to consult 2 trees of data to generate the HTML, but I have not been able to...
2
by: Andreas Håkansson | last post by:
Seeing how my previous post seem to have fallen between the cracks, I thought I would have a second, more direct, go at it. So my question is "Is it possible to group (Muenchian method) over...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
5
by: Mr Newbie | last post by:
Hi, I have tables which are going to display working hours ( Timesheet ) I was wondering the best way to total them. The grid is filled with data from a query bound to a table. Does anyone have...
2
by: Henrootje | last post by:
I have a report concerning a customer. In this report we find four subreports. They are in layout identical but data comes from different tabel. Now on the main report I count the totals of each...
0
by: ZRexRider | last post by:
Hi, I have a report driven by a SQL database. I have a populated recordset having a user name and a number of data/time fields. I process these time fields in the report's Detail_Print event. ...
4
by: mantrid | last post by:
I have records from a database that are extracted with php and displayed in a table. Data in some of the fields is replicated eg something1,item1,somethingelse1 something1,item1,somethingelse2...
2
by: bassman | last post by:
In a simple grouping and totalling query, the values 153.98 and 91.65 appear in a field within a group of records and will be summed by the query. It doesn't take much to figure that the answer...
0
by: Roman Bertle | last post by:
Hello, I try to format monetary values using the locale module, python2.5: Python 2.5.2a0 (r251:54863, Jan 3 2008, 17:59:56) on linux2 Type "help", "copyright", "credits" or "license" for...
1
by: filippo nanni | last post by:
Hello, I have a new question about organizing multidimensional arrays. I have an array containing several others; my aim is to obtain a new array, which groups together those arrays from the first...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...

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.