Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: Patrick Danso
  Where is Patrick Danso?
 Accra
 Ghana
 Patrick Danso
 Tags
Subject: RE: Append Records to Another Table
Thread ID: 345245 Message ID: 345247 # Views: 49 # Ratings: 3
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Monday, May 21, 2012 12:10:51 PM         
   


> I have a table by name payments, which keep records of all members payments and i have created another table called Rpay with the same fields as the payments table. In the payments table there are duplicate records since one member can pay his contribution many time in a given year, I want to append from the payments table to the Rpay table each record so that my Rpay table will not have duplicates records.
>
> Payments table;
> MemberID date Name
> 0001 01/01/12 Hook
> 0052 01/01/12 James
> 0003 13/02/12 Fred
> 0001 23/02/12 Hook
> 0011 25/02/12 Pat
> 0052 13/03/12 Peter
>
> I want my result as below
> Rpay table;
> MemberID date Name
> 0001 01/01/12 Hook
> 0052 01/01/12 James
> 0003 13/02/12 Fred
> 0011 25/02/12 Pat
>
> Thank you
> your text here
> your text here

Does it matter which date is saved? What happened to Peter?

ZAP IN Rpay
INSERT INTO Rpay (memberid, date, name) SELECT memberid, MIN(date),name FROM Payments GROUP BY memberid,name

-Anders

ENTIRE THREAD

Append Records to Another Table Posted by Patrick Danso @ 5/21/2012 11:44:25 AM
RE: Append Records to Another Table Posted by Anders Altberg @ 5/21/2012 12:10:51 PM
RE: Append Records to Another Table Posted by Patrick Danso @ 5/21/2012 6:40:21 PM
RE: Append Records to Another Table Posted by Patrick Danso @ 5/21/2012 7:37:06 PM
RE: Append Records to Another Table Posted by Anders Altberg @ 5/21/2012 8:59:47 PM