g1301_1400.s1393_capital_gainloss.script.sql Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
The newest version!
# Write your MySQL query statement below
# #Medium #LeetCode_Curated_SQL_70 #Database #SQL_I_Day_9_Control_of_Flow
# #2022_07_26_Time_428_ms_(92.01%)_Space_0B_(100.00%)
SELECT stock_name, SUM(CASE WHEN operation='Sell' THEN price ELSE -price END) AS capital_gain_loss
FROM Stocks GROUP BY stock_name;
© 2015 - 2024 Weber Informatics LLC | Privacy Policy