query problem

admin

Administrator
Staff member
this query is giving me problems :

$sql = "select u.username, u.cash, (u.cash + sum (s.value * p.number)) as total_value
from (users u left join (portfolio p left join shares s on s.code = p.share) on u.user_id = p.user_id)
group by u.username, u.cash
order by total_value desc";


For all those people who don't have any records in table "portfolio", I get an " " as value of "total_value". This is not the same as the cash (which is returned correctly). However, since there are no records in portfolio, in that case cash and total_value should be the same. anybody know why ?
 
Back
Top