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
4 2087
Just sort it. Thanks to your funny date format you have to sort the date using the substr() function. - SELECT * FROM test
-
WHERE client=1
-
ORDER BY
-
SUBSTR(date,7,2) DESC,
-
SUBSTR(date,4,2) DESC,
-
SUBSTR(date,1,2) DESC
-
LIMIT 1;
Ronald :cool:
Just sort it. Thanks to your funny date format you have to sort the date using the substr() function. - SELECT * FROM test
-
WHERE client=1
-
ORDER BY
-
SUBSTR(date,7,2) DESC,
-
SUBSTR(date,4,2) DESC,
-
SUBSTR(date,1,2) DESC
-
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
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?
What version of MySQL are you using?
Version 5.0.27 -community-nt via TCP/IP
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
by: TSD 2006 |
last post by:
*********************************************************
TSD 2006 - CALL FOR PARTICIPATION
*********************************************************
Ninth International Conference on TEXT,...
|
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...
|
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...
|
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....
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |