[SQL] DISTINCT ON troubles

2004-02-19 Thread Jeremy Smith
Hi, I have a query that reads: SELECT DISTINCT ON (messageboard.threadid) messageboard.threadid, messageboard.topic, owner.ownerid, owner.username FROM messageboard, owner WHERE messageboard.ownerid=owner.ownerid AND messageboard.leagueid = '$leagueid' ORDER BY messageboard.messageid DESC LIMIT $

Re: [SQL] DISTINCT ON troubles

2004-02-19 Thread Josh Berkus
Jeremy, > Am I just approaching this all wrong and need to create a temporary table > and draw from that, or is there a way to salvage this query? Think about using a subquery instead of the DISTINCT ON approach. I don't think you can get what you want with DISTINCT ON. A temporary table is n

Re: [SQL] DISTINCT ON troubles

2004-02-19 Thread Jeremy Smith
Thanks Josh, I'll do that, I just wasn't sure if I was missing something obvious. Jeremy -Original Message- From: Josh Berkus [mailto:[EMAIL PROTECTED] Sent: Thursday, February 19, 2004 2:29 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [SQL] DISTINCT ON trouble

Re: [SQL] DISTINCT ON troubles

2004-02-19 Thread Brian Knox
( sorry if this is a repeat, my mail server is being wonky today ) I'm looking for a way, within SQL, given a starting date and an ending date, to get back the number of months between the start and end date. If I "SELECT end_date - start_date", I get back an interval in days; I need months. T

Re: [SQL] DISTINCT ON troubles

2004-02-19 Thread scott.marlowe
On Thu, 19 Feb 2004, Brian Knox wrote: > ( sorry if this is a repeat, my mail server is being wonky today ) > > I'm looking for a way, within SQL, given a starting date and an ending > date, to get back the number of months between the start and end date. > If I "SELECT end_date - start_date",

Re: [SQL] DISTINCT ON troubles

2004-02-19 Thread scott.marlowe
On Thu, 19 Feb 2004, scott.marlowe wrote: > On Thu, 19 Feb 2004, Brian Knox wrote: > > > ( sorry if this is a repeat, my mail server is being wonky today ) > > > > I'm looking for a way, within SQL, given a starting date and an ending > > date, to get back the number of months between the start