If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > foxpro 206/access based query to get subtoal and totals of groups

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-27-08, 10:46
sunil3071 sunil3071 is offline
Registered User
 
Join Date: Apr 2008
Posts: 3
foxpro 206/access based query to get subtoal and totals of groups

D/friends

i need a query (foxpro 26 based or access based) to get subtotal and total s of row.. e.g

item field1 field2 field3

a
a
a
subtotal subtotal subtotal


b
b
b

subtotal subtotal subtotal

total total total
Reply With Quote
  #2 (permalink)  
Old 04-27-08, 10:51
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
I wouldn't do subtotals with a query. I'd build the query to feed the line items of the report, then build the subtotaling into the report itself (using groups).

-PatP
Reply With Quote
  #3 (permalink)  
Old 04-27-08, 10:53
sunil3071 sunil3071 is offline
Registered User
 
Join Date: Apr 2008
Posts: 3
ok dear plz give the query
Reply With Quote
  #4 (permalink)  
Old 04-27-08, 10:54
sunil3071 sunil3071 is offline
Registered User
 
Join Date: Apr 2008
Posts: 3
Quote:
Originally Posted by Pat Phelan
I wouldn't do subtotals with a query. I'd build the query to feed the line items of the report, then build the subtotaling into the report itself (using groups).

-PatP
plz give thr query
Reply With Quote
  #5 (permalink)  
Old 04-27-08, 12:20
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Code:
SELECT item, field1, field2, field3
   FROM myTable
   WHERE ?
You'll need to change the table and column names to match your existing schema, and replace the question mark with the appropriate criteria for your reporting needs.

-PatP
Reply With Quote
  #6 (permalink)  
Old 04-27-08, 16:03
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Access doesn't have anything native that will get you that. You can "spoof" it with three union queries. SQL Server has some syntax for this (Pat - I'm thinking this is a requirement met by CUBE). No idea re Foxpro.

If this is for a report then it is A LOT easier and more efficient to do this in the report - forget the query.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #7 (permalink)  
Old 04-27-08, 19:24
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Given the two applications available (Access and FoxPro) I would guess that this is a reporting need; in which case they can both do it very eeasily if you simply select the fields and group them on the report!

field1, field2 and field3 can go in the report deail section and then you can use aggregate expressions in the group section or footer sections as necessay.

In fact, yo may have to use a group by clause in your select statement...
__________________
George
Twitter | Blog
Reply With Quote
  #8 (permalink)  
Old 05-12-08, 12:53
Chico Chico is offline
Registered User
 
Join Date: May 2008
Posts: 1
Hi,

You can use sum() function in foxpro to accomplish
In this example you are adding the values in column in_stock and on_order for
all the records and saving into two variables respectively.
ex:

SUM in_stock, on_order

TO gnInStock, gnOnOrder


* Printing to the screen the calculated values in the variables
CLEAR

?

? 'Total in stock : ', gnInStock && Displays 3119.00

? 'Total on order: ', gnOnOrder && Displays 780.00
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On