473,657 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting Last payment information

9 New Member
Hi,

Let's say I have a table containing payment information:

CustID, PaymentDate, PaymentAmount. Here is some sample data:


CustID Date Amount
01 01/01/07 50.00
01 02/01/07 100.00
01 12/31/06 275.00

I'm interested in the last payment date and the amount paid on that last payment date. Is there a quick/easy way to do this?

Thanks,

Keith
Jan 30 '07 #1
4 2112
ronverdonk
4,258 Recognized Expert Specialist
Just sort it. Thanks to your funny date format you have to sort the date using the substr() function.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM test 
  2.   WHERE client=1
  3.   ORDER BY 
  4.     SUBSTR(date,7,2) DESC, 
  5.     SUBSTR(date,4,2) DESC, 
  6.     SUBSTR(date,1,2) DESC 
  7. LIMIT 1;
Ronald :cool:
Jan 30 '07 #2
kjflash
9 New Member
Just sort it. Thanks to your funny date format you have to sort the date using the substr() function.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM test 
  2.   WHERE client=1
  3.   ORDER BY 
  4.     SUBSTR(date,7,2) DESC, 
  5.     SUBSTR(date,4,2) DESC, 
  6.     SUBSTR(date,1,2) DESC 
  7. LIMIT 1;
Ronald :cool:

Thanks for your reply. I should have included more detail.

Let's say I have the customer list below:

01 John
02 Tom
03 Paul

And I have them making the following payments (Date formatting is unimportant)

01 03/12/06 $100.00
03 04/14/06 $42.50
03 12/31/06 $12.75
01 01/01/06 $167.00

I want a query that will show me the latest payment and payment amount for each Customer and return the following result set:

01 John 03/12/06 $100.00
02 Tom Null Null
03 Paul 12/31/06 $12.75

Thanks again for any help.

Keith
Jan 30 '07 #3
Motoma
3,237 Recognized Expert Specialist
Thanks for your reply. I should have included more detail.

Let's say I have the customer list below:

01 John
02 Tom
03 Paul

And I have them making the following payments (Date formatting is unimportant)

01 03/12/06 $100.00
03 04/14/06 $42.50
03 12/31/06 $12.75
01 01/01/06 $167.00

I want a query that will show me the latest payment and payment amount for each Customer and return the following result set:

01 John 03/12/06 $100.00
02 Tom Null Null
03 Paul 12/31/06 $12.75

Thanks again for any help.

Keith
What version of MySQL are you using?
Jan 30 '07 #4
kjflash
9 New Member
What version of MySQL are you using?

Version 5.0.27 -community-nt via TCP/IP
Jan 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
13049
by: Robert Brown | last post by:
Hi All, I am creating an interface into a Payment Gateway. I need to access a URL (which is a perl script) with paramters attached. I will then get a response within 10 seconds with information I need to formulate into my pretty asp page. I didn't know where to start but I have read alot about adodb.stream. I setout to write some code and this is what I have done:
2
1523
by: Paul H | last post by:
My customer has an ecommerce store. He receives approx 600 orders per month. Worldpay.com handles the credit card transactions and sends my customer an email for each order containing the information exactly as shown below. We need to get the Shoppers details, Shipping details and the product details out of Outlook and into Access. I can take care of the database construction, but I just need some advice on how best to format the Worldpay...
4
3393
by: New Guy | last post by:
I'm trying to work with a system that somebody else built and I am confounded by the following problem: There is a table of payments and a table of charges. Each client has charges and payments during the month. I'd like to get the totals of the payments and of the charges for each client. When I run the following query, I get huge numbers that appear as if the join is not working correctly.
0
1698
by: TSD 2006 | last post by:
********************************************************* TSD 2006 - CALL FOR PARTICIPATION ********************************************************* Ninth International Conference on TEXT, SPEECH and DIALOGUE (TSD 2006) Brno, Czech Republic, 11-15 September 2006 http://www.tsdconference.org/ The conference is organized by the Faculty of Informatics, Masaryk University, Brno, and the Faculty of Applied Sciences, University of
3
1763
by: rlbSQL | last post by:
I am trying to find the last payment date made to a vendor in a table. This table has many vendors I will need to have a line for each vendor and what thier last payment date is. I assume it would something like this. SELECT vendor_id, MAX(invoice_date) AS last_invoice_date FROM MIL_VENDOR_INVOICE_PAYMENT_MT GROUP BY vendor_id;
1
2697
by: myemail.an | last post by:
Hi all, I am a novice to Access, and was wondering if I could get some help on a problem I can't solve. I have a database with customer payments, structured like this: customer code type of payment date of payment payment amount
2
3098
by: scott | last post by:
Hi Everyone, I have a table which has many fields in it but I need to pull some specific info via a query and I don't know if it's possible. I want to run a query which includes two tables. Participants and Payments. They are linked so that a participant can make many payments and a report can then be printed on all payments that participant has made. What I want to do is have a field in the payments table that has a "PaidTo"
8
2048
by: gnewsgroup | last post by:
I have never done anything involving handling credit card payment online. I searched this forum a little bit, and found a few related questions. But, I am still not clear how the solutions they talked about work. I do NOT want my users to go to another domain (either through a popup window or not) to make the payment and redirected back to my web site, because this does not sound professional. In other words, I would like to handle...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.