[SQL] Many-to-one subquery

2000-08-16 Thread Martin Christensen

I have a problem that I have not been able to solve efficiently, and
I'm confident that it can be done in a single query.

I have a mailing list archive that I want to do some statistics on. It
would tremendously ease my work if I could extract such statistics for
each individual poster in one go. That would, of course, be quite
easy, if I could do a SELECT DISTINCT poster FROM maillist as a
subquery and use that as an argument. For instance, if I have a
function postpct(date, date, varchar(30)) that calculates the
percentage of posts that a certain poster ($3) is responsible in a
certain time interval ($1 to $2), then how do I go about feeding that
function all distinct poster entries? I've tried different things with
joins, but the bit that actually worked was horribly inefficient.

Martin

-- 
GPG public key: http://home1.stofanet.dk/factotum/gpgkey.txt



Re: [SQL] fetching rows

2000-10-30 Thread Martin Christensen

> "Jeff" == Jeff Hoffmann <[EMAIL PROTECTED]> writes:
Jeff> you can't do that with a cursor, but you can use they mysql-ism
Jeff> called a limit clause.  for example, to fetch rows 26-50 from
Jeff> that query, you'd do:
Jeff> select * from films limit 25,26;
Jeff> or
Jeff> select * from files limit 25 offset 26;

Since there's no particular ordering of the output of such a query it
is necessary to explicitly state an ordering key. Otherwise you'll
quickly find that the phase of the moon has very significant influence
on the produced results. :-) Especially in 7.*, as I understand it.

Martin

-- 
GPG public key: http://home1.stofanet.dk/factotum/gpgkey.txt