Hi Tom,
I don't think there is a straight way in Mysql to accomplish this. It
would have been great if Mysql included this provision.
I suggest you to use temporary tables. First make a temporary table
inserting values of job and the maximum date of inv for the job.
Create temporary table te
hum, I think it won't acheive his goal:)
Let's say you have this as data:
| id |date| whatever |
||
| 1 | 2001-11-26 | |
| 2 | 2001-11-27 | |
| 3 | 2001-11-25 | |
| 4 | 2001-11-27 | |
| 5 |
Tom,
Restating the problem, you want the last two from the set ordered by
invoice date. So, add
ORDER BY site_service.invoice_date DESC
LIMIT 2;
Probably just a typo, but I note your statement selects site_service.id
and site.site_id but has site_service.site_id = site.id in the WHERE
clause.
I'm trying to write a query that will limit the results but not by the total
amount returned like a normal LIMIT. It's an invoice database and I would
like to return the last to invoices for a certain job. So if there are 100
jobs with several invoice dates I would like to return a web page displa