Welcome Guest, Not a member yet? Register   Sign In
Calculate position based on a value
#2

(This post was last modified: 12-14-2015, 09:36 AM by keulu.)

hi guy girl,

watch your error Smile

SELECT a1.from_user_id, a1.total_stats, COUNT(a2.total_stats) position
FROM score a1, score a2
VS
$this->db->select('a1.from_user_id, a1.total_stats, COUNT(a2.total_stats) position');
$this->db->from('score');

try to do this

$this->db->from('score a1, score a2');

but i didn't understand why you used 2 aliases for the same Table ?

can't you do this ?

SELECT from_user_id, total_stats, COUNT(total_stats) AS position
FROM score
WHERE total_stats <= position AND from_user_id=25030
GROUP BY from_user_id, total_stats
ORDER BY total_stats DESC, from_user_id DESC
Reply


Messages In This Thread
Calculate position based on a value - by Violette - 12-14-2015, 08:09 AM
RE: Calculate position based on a value - by keulu - 12-14-2015, 09:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB