题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
--解决方案(1) selectstock_name, sum(casewhenoperation="Buy"then-priceelsepriceend) ascapital_gain_lossfromStocksgroupbystock_name--解决方案(2) SELECTstock_name, SUM(IF(operation='Sell', price, 0)) -SUM(IF(operation='Buy', price, 0)) capital_gain_lossFROMStocksGROUPBYstock_name