Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Totaling records in an sql
Message
From
13/08/2003 12:24:30
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Totaling records in an sql
Miscellaneous
Thread ID:
00819829
Message ID:
00819829
Views:
50
Hello everybody.

i know i've seen the solution here at UT before, but can't remember where it was (working in Vfp6 sp 5).

I have a header sales order table (comast) and a detail sales order table (codet) where there are multible (or one) records for each sales order. what i need is a sql command which totals those records, giving me one record for each customer and for a specific month (or month range).

i have currently:
SELECT ;
		b.custid, ;
		a.usell*a.qtyord as usell, ;
		b.reqdate ;
	FROM "codet" a, "comast" b ;
	WHERE ;
		inlist(b.custid, padr("32312", 8)) .and. ;
		a.Custid = b.custid .and. ;
		BETWEEN(b.reqdate, date(), DATE()+(31)) ;
	ORDER BY b.reqdate ;
	INTO CURSOR cur_Temp
this gives me a table with all detail records for the customer (ID) "32312" and the due date (reqdate) between today and 31 days from now.

I need to end up with one record per customer + per month. Those records need to have a total dollar amount (a.usell*a.qtyord) for this time frame + for this customer. as you can see i used 'InList()' to select the customer, as i might whant to do this with a range of customers.

i am not that familier when it comes to complex sql like this one.
i was thinking of using the group clause somehow, but was unsuccessfull with this.

any help is as alway greatly appreaciated.
Next
Reply
Map
View

Click here to load this message in the networking platform