Re: [GENERAL] simple query question: return latest

2004-11-15 Thread Jerry III
SELECT "date" FROM "table" WHERE "color" = 'red' ORDER BY "date" DESC LIMIT 1; Don't worry about names, just quote your identifiers. They will stand out and you can use anything you want. Jerry "Michael Glaesemann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Scott, > > On No

Re: [GENERAL] simple query question: return latest

2004-11-12 Thread Scott Frankel
On Nov 12, 2004, at 8:24 AM, Michael Fuhr wrote: [Top-posting fixed] On Fri, Nov 12, 2004 at 09:06:08AM -0500, Goutam Paruchuri wrote: Scott Frankel wrote: ORDER BY DESC LIMIT 1 is much simpler and more readable than a sub-query. Though the sub-query approach looks to be a good template for ensuri

Re: [GENERAL] simple query question: return latest

2004-11-12 Thread Michael Fuhr
[Top-posting fixed] On Fri, Nov 12, 2004 at 09:06:08AM -0500, Goutam Paruchuri wrote: > Scott Frankel wrote: > > > ORDER BY DESC LIMIT 1 is much simpler and more readable than a > > sub-query. Though the sub-query approach looks to be a good template > > for ensuring more accurate results by bei

Re: [GENERAL] simple query question: return latest

2004-11-12 Thread Goutam Paruchuri
entable g2 WHERE g2.color= g.color ) LIMIT 1 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Scott Frankel > Sent: Thursday, November 11, 2004 11:13 PM > To: [EMAIL PROTECTED] > Subject

Re: [GENERAL] simple query question: return latest

2004-11-11 Thread Scott Frankel
ORDER BY DESC LIMIT 1 is much simpler and more readable than a sub-query. Though the sub-query approach looks to be a good template for ensuring more accurate results by being more explicit. Thanks to all who responded! Scott SELECT * FROM colortable WHERE color = 'red' ORDER BY date DESC LIMIT

Re: [GENERAL] simple query question: return latest

2004-11-11 Thread Michael Fuhr
On Thu, Nov 11, 2004 at 05:00:46PM -0800, Scott Frankel wrote: > How does one return the latest row from a table, given multiple entries > of varying data? > i.e.: given a table that looks like this: > > color | date > + > red| 2004-01-19 > blue | 2004-05-24 > red

Re: [GENERAL] simple query question: return latest

2004-11-11 Thread Stephan Szabo
On Thu, 11 Nov 2004, Scott Frankel wrote: > > On Nov 11, 2004, at 5:09 PM, Michael Glaesemann wrote: > > > Scott, > > > > On Nov 12, 2004, at 10:00 AM, Scott Frankel wrote: > > > >> color | date > >> + > >> red| 2004-01-19 > >> blue | 2004-05-24 > >> red| 2004-04-

Re: [GENERAL] simple query question: return latest

2004-11-11 Thread Scott Frankel
On Nov 11, 2004, at 5:09 PM, Michael Glaesemann wrote: Scott, On Nov 12, 2004, at 10:00 AM, Scott Frankel wrote: color | date + red| 2004-01-19 blue | 2004-05-24 red| 2004-04-12 blue | 2004-05-24 How do I select the most recent entry for 'red'? SELECT color, MAX(

Re: [GENERAL] simple query question: return latest

2004-11-11 Thread Vincent Hikida
PROTECTED]> Sent: Thursday, November 11, 2004 5:09 PM Subject: Re: [GENERAL] simple query question: return latest > Scott, > > On Nov 12, 2004, at 10:00 AM, Scott Frankel wrote: > > > color | date > > + > > red| 2004-01-19 > >

Re: [GENERAL] simple query question: return latest

2004-11-11 Thread Michael Glaesemann
Scott, On Nov 12, 2004, at 10:00 AM, Scott Frankel wrote: color | date + red| 2004-01-19 blue | 2004-05-24 red| 2004-04-12 blue | 2004-05-24 How do I select the most recent entry for 'red'? SELECT color, MAX(date) FROM giventable WHERE color = 'red' -- omit this

[GENERAL] simple query question: return latest

2004-11-11 Thread Scott Frankel
Still too new to SQL to have run across this yet ... How does one return the latest row from a table, given multiple entries of varying data? i.e.: given a table that looks like this: color | date + red| 2004-01-19 blue | 2004-05-24 red| 2004-04-12 blue | 2004