I have the below query that works fine:
SELECT SUM(t.myvotes) FROM
(
SELECT ( SUM(votes.rating) / (DATEDIFF(UTC_TIMESTAMP(), posts.pubdate)+1) ) AS myvotes
FROM votes
INNER JOIN posts ON votes.post_id = posts.post_id
WHERE posts.profile_id = 142795
GROUP BY votes.post_id
) AS t
However I wish to select additional colums and also have the WHERE selector out of the subselect ie:
SELECT profile_id, profile_name, SUM(t.myvotes) ...
...
WHERE profile_id = 123456
Also I would like to return the same result for all profile_id's ie.
SELECT profile_id, profile_name, SUM(t.myvotes) ...
...
GROUP BY profile_id
How would I do the above?