I cannot figure out this query:
Code: Select all
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 shareshow about this: IF(t_type='sell',-shares,shares)
t_type and shares are table fields
Thanks for your help