List:General Discussion« Previous MessageNext Message »
From:Harald Fuchs Date:May 26 2004 10:00am
Subject:Re: need help with a complicated join
View as plain text  
In article <puy8nf8r1b.fsf@stripped>,
Harald Fuchs <hf517@stripped> writes:

>   SELECT q.symbol, q.date,
>          q.quote * product (s.split_from / s.split_to) AS adjusted_quote
>   FROM quotes q
>   LEFT JOIN splits s ON s.symbol = q.symbol AND s.date > q.date
>   GROUP BY q.symbol, q.date, q.quote
>   ORDER BY q.symbol, q.date

> The problem is how to define the 'product' aggregate (along the lines
> of 'sum').

[ I like talking to myself :-) ]

A workaround for the missing product aggregate would be

  SELECT q.symbol, q.date, q.quote,
         q.quote * exp(sum(log(coalesce(s.split_from/s.split_to,1))))
  FROM quotes q
  LEFT JOIN splits s ON s.symbol = q.symbol AND s.date > q.date
  GROUP BY q.symbol, q.date, q.quote
  ORDER BY q.symbol, q.date

but don't ask me how that performs...

Thread
need help with a complicated joinmysql25 May
  • Re: need help with a complicated joinHarald Fuchs26 May
  • Re: need help with a complicated joinHarald Fuchs26 May
    • RE: need help with a complicated joinelectroteque26 May
    • Re: need help with a complicated joinHarald Fuchs26 May
  • Re: need help with a complicated joinRobert A. Rosenberg26 May
Re: need help with a complicated joinSGreen25 May
Re: need help with a complicated joinSGreen26 May
  • RE: need help with a complicated joinmysql26 May