Re: How to select the last entry per item

2006-04-28 Thread Peter Brawley
Here are the queries which illustrate Shawn's point. Now to sleep. -- wrong DROP TABLE IF EXISTS o1; CREATE TABLE o1 SELECT customerid,shipcity,MAX(shippeddate) AS latest FROM orders GROUP BY customerid; -- right DROP TABLE IF EXISTS o2; CREATE TABLE o2 SELECT DISTINCT o1.customerid,o1.shipc

Re: How to select the last entry per item

2006-04-28 Thread Peter Brawley
LOL, three late nights in a row, lose that last post o' mine. PB - Shawn Green wrote: --- Peter Brawley <[EMAIL PROTECTED]> wrote: Brian Hi, I hope this is the right list for this question. If not, I'm happy to get help on where to post this question. Apo

Re: How to select the last entry per item

2006-04-28 Thread Peter Brawley
Shawn, Yep that's the theory, but where (i) the aggregate result is a column value, rather than a sum or average for example, and (ii) id is unique, I have not been able to get MySQL to give a wrong value with that approach, eg try the following with the northwind database (it ought to be doa

Re: How to select the last entry per item

2006-04-28 Thread Shawn Green
--- Peter Brawley <[EMAIL PROTECTED]> wrote: > Brian > > Hi, > > > > I hope this is the right list for this question. If not, I'm happy > > to get help on where to post this question. Apologies in advance > if > > this is an old question. > > > > We are designing a simple a tracking database w

Re: How to select the last entry per item

2006-04-27 Thread Peter Brawley
Brian Hi, I hope this is the right list for this question. If not, I'm happy to get help on where to post this question.  Apologies in advance if this is an old question. We are designing a simple a tracking database with a table of entries showing the current location of each it

Re: How to select the last entry per item

2006-04-27 Thread Terry Burton
On 4/27/06, Brian J. Matt <[EMAIL PROTECTED]> wrote: > As the items move new time stamped entries are added to the > database. How would you query to find the current location of all > the items currently in the system. As you might expect we don't want > to replace the entry for an item when a l

RE: How to select the last entry per item

2006-04-27 Thread Tim Lucia
@lists.mysql.com Subject: How to select the last entry per item Hi, I hope this is the right list for this question. If not, I'm happy to get help on where to post this question. Apologies in advance if this is an old question. We are designing a simple a tracking database with a table of entries showin

How to select the last entry per item

2006-04-27 Thread Brian J. Matt
Hi, I hope this is the right list for this question. If not, I'm happy to get help on where to post this question. Apologies in advance if this is an old question. We are designing a simple a tracking database with a table of entries showing the current location of each item in the system.