Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Ryan Lashway
  Where is Ryan Lashway?
 Warrensburg
 New York - United States
 Ryan Lashway
 To: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 Tags
Subject: RE: Combind Records
Thread ID: 202104 Message ID: 202261 # Views: 26 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Thursday, November 06, 2008 3:33:33 PM         
   


> >
> > Jun,
> >
> > Thanks for the post, the code worked with your example but I can not get it to work with my data. I have about 30 fields in this table, do I need to cast them all
> >
> > Select TOQtemp
> > Goto Top
> > Select field1, field2, field4, field5, field6,P_ID,;
> > Cast(Sum(field4) As N(12,2)) As item1,;
> > CAST(Sum(field5) As N(12,2)) As item2,;
> > CAST(Sum(field6) As N(12,2)) As Total;
> > FROM TOQtemp Group By P_ID, field2
> > Browse
> >
> > This is the code I am trying to execute but still get the SQL Group error.
> >
> > Ryan J. Lashway
> > http://www.lashtech.com
>
> No you dont need to CAST() anything. The Standard SQL rule, incorporated in VFP9, says that for a
> SELECT columnlist GROUP BY columnlist
> the two column lists must include all the same columns (eccept for the aggregation function columns, i e the SUM(), COUNT(), MIN(), MAX(), or AVG() group aggegations.
> Just so the one knows exactly what the sum applies to.
> Take
>
 custid, amount, city 
> 123 10 London
> 123 20 Paris
> 123 5 New York

>
SELECT custid, city, SUM(amount) FROM table GROUP BY custid

> It's easy to see that the sum for custid 123 should be 35 but which city is correct?
>
> -Anders

Same error, changed code to look like


Ryan J. Lashway
http://www.lashtech.com



COMPLETE THREAD
Combind Records Posted by Ryan Lashway @ 11/5/2008 11:34:59 PM
RE: Combind Records Posted by Jun Tangunan @ 11/5/2008 11:51:12 PM
RE: Combind Records Posted by Cetin Basoz @ 11/5/2008 11:52:28 PM
RE: Combind Records Posted by Ryan Lashway @ 11/6/2008 12:40:27 AM
RE: Combind Records Posted by Jun Tangunan @ 11/6/2008 1:14:45 AM
RE: Combind Records Posted by Ryan Lashway @ 11/6/2008 2:30:00 PM
RE: Combind Records Posted by Anders Altberg @ 11/6/2008 2:53:08 PM
RE: Combind Records Posted by Ryan Lashway @ 11/6/2008 3:33:33 PM
RE: Combind Records Posted by tushar @ 11/6/2008 4:05:25 PM
RE: Combind Records Posted by Anders Altberg @ 11/6/2008 5:09:32 PM
RE: Combind Records Posted by Ryan Lashway @ 11/6/2008 8:33:13 PM
RE: Combind Records Posted by Anders Altberg @ 11/6/2008 10:39:35 PM
RE: Combind Records Posted by Cetin Basoz @ 11/6/2008 4:06:22 PM
RE: Combind Records Posted by Mike Yearwood @ 11/6/2008 3:21:48 PM
RE: Combind Records Posted by Ryan Lashway @ 11/6/2008 9:36:42 PM