31.03.2022 akışı
Mysql bulk insert Link
Mysql query starts with Link
Mysql find duplicate records Link
SELECT t.Login, t.Symbol, t.TotalOrderCount, t.TotalVolume, t.CMD,
CASE t.CMD WHEN 0 THEN 'SELL' ELSE 'BUY' END AS OrderType
FROM (
SELECT
T_ORDER1.LOGIN AS Login,
T_ORDER1.SYMBOL AS Symbol,
COUNT(T_ORDER1.CMD) AS TotalOrderCount,
SUM(T_ORDER1.VOLUME) AS TotalVolume,
T_ORDER1.CMD AS CMD
FROM MT4_TRADES AS T_ORDER1
WHERE
T_ORDER1.LOGIN IN (SELECT LOGIN FROM MT4_USERS WHERE LOGIN > 10001 AND BALANCE != EQUITY)
AND T_ORDER1.CLOSE_TIME = '1970-01-01 00:00:00'
AND (T_ORDER1.CMD = 0 )
AND T_ORDER1.VOLUME >=100
GROUP BY Login, Symbol
UNION ALL
SELECT
T_ORDER2.LOGIN AS Login,
T_ORDER2.SYMBOL AS Symbol,
COUNT(T_ORDER2.CMD) AS TotalOrderCount,
SUM(T_ORDER2.VOLUME) AS TotalVolume,
T_ORDER2.CMD AS CMD
FROM MT4_TRADES AS T_ORDER2
WHERE
T_ORDER2.LOGIN IN (SELECT LOGIN FROM MT4_USERS WHERE LOGIN > 10001 AND BALANCE != EQUITY)
AND T_ORDER2.CLOSE_TIME = '1970-01-01 00:00:00'
AND (T_ORDER2.CMD = 1)
AND T_ORDER2.VOLUME >=100
GROUP BY Login, Symbol
)
AS t
ORDER BY t.login, t.SYMBOL
Yorumlar
Yorum Gönder