Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Question How To?
Message
 
 
To
03/02/2006 23:54:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01093476
Message ID:
01093639
Views:
24
>Thank you gentleman that is exactly what I needed! One more question regarding the same data set. How can I retrieve just the last or most recent contribution? I know I can use MAX() for the contribution date but will that only return the contribution date or the amount also?

Hi Jeff,

You can get most recent contribution with MAX() but not the way you're thinking.
SELECT * FROM Contributions c1 
  WHERE NOT EXISTS (
              SELECT * FROM Contributions c2
                WHERE c2.cDonors_id = c1.cDonors_id 
                   AND c2.ContributionDate > c1.ContributionDate)
* or 
SELECT * FROM Contributions c1 
  WHERE ContributionDate = (
              SELECT MAX(ContributionDate) FROM Contributions c2
                WHERE c2.cDonors_id = c1.cDonors_id )
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform