
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
# Write your MySQL query statement below
# #Medium #LeetCode_Curated_SQL_70 #Database #SQL_I_Day_9_Control_of_Flow
# #2022_05_24_Time_457_ms_(79.39%)_Space_0B_(100.00%)
SELECT
stock_name,
SUM(IF (operation = 1, price, -1 * price)) AS capital_gain_loss
FROM
Stocks
GROUP BY
stock_name
ORDER BY
operation_day asc;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy