Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group By - Continued Help Needed
Message
From
17/03/2004 12:21:19
N. Lea
Nic Cross Enterprises
Valencia, California, United States
 
 
To
17/03/2004 12:16:24
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00887107
Message ID:
00887147
Views:
17
Still the same result. The are multiple values for id_desc that are the same result, which is why I was hoping it would group them together with the approriate sum that was calculated. Like I said strange that it would in VFP 7. If I switch the behavior, it works, but what would the use be then of switching to 8

>I was just going to say it doesn't look like the result of a group by. Maybe your values are double (but displayed with 2 decimals). What does this would show ?
>
>select id_desc,round(sum_ap_total,2) as sum_ap_tot ;
> from sql_ap_pre ;
> where ap_status = .pcStatus ;
> group by id_desc, sum_ap_tot ;
> order by id_desc, sum_ap_tot
>
>Cetin
>
>
>
>>Unfortunately, as I had tried that before, which is why I limited the fields for the group by statement. It was not combining the information together. The code presented from you (and I have used it) created this information:
>>
>>AP-MISC                        500.00
>>AP-OFFICESUPPLIES              500.00
>>AP-OFFICESUPPLIES              500.00
>>AP-OFFICESUPPLIES             2000.00
>>AP-COMPUTERS                  5000.00
>>AP-COMPUTERS                  3000.00
>>AP-COMPUTERS                  7000.00
>>AP-COMPUTERS                  1500.00
>>AP-OFFICESUPPLIES               50.00
>>AP-MISC                       1000.00
>>
>>
>>where as I am trying to accomplish:
>>
>>AP-COMPUTERS                  11500.00
>>AP-OFFICESUPPLIES              3050.00
>>AP-MISC                        1500.00
>>
>>
>>for some reason it does not want to group the codes together, it just wanted to keep them seperated.
>>
>>
>>
>>>>>>Hello,
>>>>>>
>>>>>>I have tried every suggestion that has been given to me regarding the whole "Group By" subject. However, I still do not seem to be accomplishing what VFP 6/7 was able to accomplish in VFP 8. I am beginning to wonder if it does work with this new SQL statement type. Everytime I attempt this "Group By" in any sense of my code, it still gives me the information seperately inside the grid. I attempted to re-write the code over and over again, but every version comes out the same or worse. I attempted the MAX() code into the fields, but destroyed my output data into figures that did not match up or correct figures that were placed multiple times.
>>>>>>
>>>>>>
>>>>>>select id_desc,sum_ap_total ;
>>>>>>from sql_ap_pre ;
>>>>>>where ap_status = .pcStatus ;
>>>>>>group by id_desc, sum_ap_total ;
>>>>>>into cursor sql_ap readwrite
>>>>>>
>>>>>>
>>>>>>The id_desc and totals are shown as:
>>>>>>
>>>>>>AP-MISC                        500.00
>>>>>>AP-OFFICESUPPLIES              500.00
>>>>>>AP-OFFICESUPPLIES              500.00
>>>>>>AP-OFFICESUPPLIES             2000.00
>>>>>>AP-COMPUTERS                  5000.00
>>>>>>AP-COMPUTERS                  3000.00
>>>>>>AP-COMPUTERS                  7000.00
>>>>>>AP-COMPUTERS                  1500.00
>>>>>>AP-OFFICESUPPLIES               50.00
>>>>>>AP-MISC                       1000.00
>>>>>>
>>>>>>
>>>>>>where as I am trying to accomplish:
>>>>>>
>>>>>>AP-COMPUTERS                  11500.00
>>>>>>AP-OFFICESUPPLIES              3050.00
>>>>>>AP-MISC                        1500.00
>>>>>>
>>>>>>
>>>>>>I even narrowed this code down thinking that it was because I have more fields originally, but even when I now have only two fields, it does not come out right. Does anyone please have a solution for this in VFP 8 aside from using the 7 Engine to calculate correctly??
>>>>>>
>>>>>>Thank you so much!!
>>>>>
>>>>>This works in 6/7 ? What's the logic behind grouping with an SQL like this ? I haven't seen your previous problem so there might be a logic in fact which I'm missing. Probably you meant to :
>>>>>
>>>>>select distinct id_desc,sum_ap_total ;
>>>>>from sql_ap_pre ;
>>>>>where ap_status = .pcStatus ;
>>>>>into cursor sql_ap readwrite
>>>>>
>>>>>I don't see the point to use group by instead. Or you mean this ?
>>>>>
>>>>>select id_desc,sum(sum_ap_total) as sum_ap_total ;
>>>>>from sql_ap_pre ;
>>>>>where ap_status = .pcStatus ;
>>>>>group by id_desc ;
>>>>>order by id_desc ;
>>>>>into cursor sql_ap readwrite
>>>>>
>>>>>Cetin
>>>>
>>>>Yes, this process work in VFP 6/7, but the Select-SQL statement was straightforward when the code worked with it. This was the original code that worked:
>>>>
>>>>
>>>>select a.id_no, a.name, b.account, b.name, sum(a.inv_total), ;
>>>a.ap_status,a.ap_code,c.id_no,c.id_desc ;
>>>>from vendors_inv a, vendor_accounts b,vendor_codes c;
>>>>where inv_status=lcoverduestatus and ;
>>>a.id_no=gnclientid and ;
>>>!empty(ap_code) and ;
>>>a.name=b.account and ;
>>>a.ap_code==c.id_no;
>>>>group by a.inv_code ;
>>>>into cursor sql_ap readwrite
>>>>
>>>>
>>>>This worked great! The system calculated the inv_total for each code and summed them together. Then in the end it grouped it by the code into one line item. Thus producing the results wished above.
>>>
>>>It should have worked great by chance. So this should work the same way in any version :
>>>
>>>>
>>>select a.id_no, a.name, b.account, b.name, sum(a.inv_total), ;
>>>       a.ap_status,a.ap_code,c.id_no,c.id_desc ;
>>>  from vendors_inv a, vendor_accounts b,vendor_codes c;
>>>  where inv_status=lcoverduestatus and ;
>>>        a.id_no=gnclientid and ;
>>>        !empty(ap_code) and ;
>>>        a.name=b.account and ;
>>>        a.ap_code==c.id_no;
>>>  group by a.inv_code,a.id_no, a.name, b.account, b.name,;
>>>        a.ap_status,a.ap_code,c.id_no,c.id_desc ;
>>>into cursor sql_ap readwrite
>>>
Cetin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform