Hi,

You can't use a temp table more than once in a query.

If you could not use table more than once you could not do self join, or variety of other things:
select * from a A1 join a A2 on A1.child_id A2.id;

--Justin

On Tue, Jun 23, 2015 at 12:17 AM, Benoit Panizzon <benoit.panizzon@imp.ch> wrote:
Hi Kristian

> Maybe try something like this (untested):
>
> SELECT *
>   FROM (SELECT mail_out_anon+mail_out_auth ss, timeslice
>           FROM domaincounters
>          WHERE domain_id=19
>          ORDER BY timeslice desc
>          LIMIT 24) tmp
>  ORDER BY ss DESC
>  LIMIT 1;

Thank you, that is the solution I was looking for.

Justin, you cannot have a subquery on the same table within your query. My
previous attempt was to return the ID's of the last 24 timeslices in a
subquery and then MAX() them. But MariaDB prevents this kind of query.

Mit freundlichen Grüssen

Benoit Panizzon
--
I m p r o W a r e   A G    -
______________________________________________________

Zurlindenstrasse 29             Tel  +41 61 826 93 07
CH-4133 Pratteln                Fax  +41 61 826 93 02
Schweiz                         Web  http://www.imp.ch
______________________________________________________

_______________________________________________
Mailing list: https://launchpad.net/~maria-discuss
Post to     : maria-discuss@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-discuss
More help   : https://help.launchpad.net/ListHelp