Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Scott Warris
  Where is Scott Warris?
 Lima
 Ohio - United States
 Scott Warris
 To: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 Tags
Subject: RE: Total Like Items in a table
Thread ID: 289167 Message ID: 289225 # Views: 31 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Wednesday, December 29, 2010 5:15:48 PM         
   


> > Hello, I've got a table that contains 1000's of records and I need to combine the like records and total the QTY field of the like items.
> >
> > My table contains the following fields ItemNum, Desc, Qty and Qtytotal
> >
> > I've thought about just appling an index with the unique command to filter out the like items but I need to store the sum Qty field to the Qtytotal field and I can't see how to do this.
> >
> > Thanks for your help..Scott
>
>
> Something like this?
>
>
CREATE CURSOR junk (itemnum i, qty n(12,2))
> INSERT INTO junk VALUES (1,5)
> INSERT INTO junk VALUES (2,5)
> INSERT INTO junk VALUES (3,45)
> INSERT INTO junk VALUES (1,22)
> INSERT INTO junk VALUES (1,28)
> INSERT INTO junk VALUES (3,15)
> INSERT INTO junk VALUES (2,3)
> INSERT INTO junk VALUES (1,6)
> INSERT INTO junk VALUES (3,4)
> 
> SELECT itemnum, SUM(qty) as totqty FROM junk GROUP BY 1

>
>
> http://www.junblogs.com/
> http://weblogs.foxite.com/sandstorm36/default.aspx
> http://www.coderisland.com/forum/viewforum.php?f=10


Thanks Jun, the select statement above looks like it will do the trick..

Thanks again for everyones replies..this is a great site..

ENTIRE THREAD

Total Like Items in a table Posted by Scott Warris @ 12/28/2010 9:50:51 PM
RE: Total Like Items in a table Posted by Anders Altberg @ 12/28/2010 10:05:28 PM
RE: Total Like Items in a table Posted by Scott Warris @ 12/29/2010 3:28:59 PM
RE: Total Like Items in a table Posted by Anders Altberg @ 12/29/2010 5:04:13 PM
RE: Total Like Items in a table Posted by Tariq mehmood @ 12/29/2010 6:31:00 AM
RE: Total Like Items in a table Posted by Jun Tangunan @ 12/29/2010 7:14:22 AM
RE: Total Like Items in a table Posted by Scott Warris @ 12/29/2010 5:15:48 PM