Tricky math SQL statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I have a tricky SQL statement which I would like to put on a MySQL 3.X DB

Not sure if this workes out with a simple statement, thats why I post it
into the php.db newsgroup. Might require some php?!

--------
OK... short description:

tablelayout:
timestamp user_id points

The goal is to get out of this table the top 3 users which have acchieved
the most points in the last 7 days.
--------

This requires some calculation within the db, as far as I know this should
be possible, but this seems a bit to complex. I tryed some statements, but
failed ;-((

Something like:

SELECT DISTINCT
    user_id
FROM
    table
WHERE
    MAX (SUM(points))
ORDER BY
    timestamp
LIMIT
    3

Thank you for any help on this. I am not a SQL expert, so I am having a real
hard time on that one.

Cheers, Merlin






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux