Hi I cannot figure out this query: SELECT symbol,SUM(IF(t_type='sell',-shares,shares)) AS shares, MAX(price) AS maxprice, MIN(price) AS minprice FROM transactions WHERE completed=0 GROUP BY symbol ORDER BY shares Code (markup): My problem is "-shares"; what does it mean? how about this: IF(t_type='sell',-shares,shares) t_type and shares are table fields Thanks for your help
SUM(IF(t_type='sell',-shares,shares)) AS shares gives you the total number of shares held after subtracting all the sales for that stock symbol Thanks Lavee