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  | 2001-11-26 |          |
| 6  | 2001-11-26 |          |
| 7  | 2001-11-25 |          |
| 8  | 2001-11-26 |          |
| 9  | 2001-11-27 |          |
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

he wants to have the data for the two last dates.

so it would be in that case:

| id |    date    | whatever |
|----------------------------|
| 2  | 2001-11-27 |          |
| 4  | 2001-11-27 |          |
| 9  | 2001-11-27 |          |
| 1  | 2001-11-26 |          |
| 5  | 2001-11-26 |          |
| 6  | 2001-11-26 |          |
| 8  | 2001-11-26 |          |
 ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

means all invoices from the two last days where there are incvoices.

I don't think he want's to use date sub from NOW() sine the two last
invoice dates might be variable..

Etienne

Michael Stassen wrote:
> 
> 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.
> 
> Michael
> 
> On Thu, 29 Nov 2001, Tom Beidler wrote:
> 
> > 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 two invoices for a certain job. So if there are 100
> > jobs with several invoice dates I would like to return a web page displaying
> > a table of invoice dates ordered by job name and LIMIT the invoice dates to
> > the last two invoice dates for each job. Here's my query so far;
> >
> > SELECT site_service.id, site_service.service_date,
> > site_service.invoice_date, site.site_id, site.name, site.state, site.status
> > FROM site_service, site WHERE site_service.site_id = site.id AND
> > site.company = 'Nextel'
> >
> > If I add LIMIT 2, I only get two invoices. I'm trying to get the last to
> > invoices for each site.
> >
> > Is this possible or is there another direction I should go? I checked out
> > the MySQL site without any luck.
> >
> > Thanks,
> > Tom
> >
> 
> Michael Stassen
> University Information Technology Services
> Indiana University Bloomington
> [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to