有没有办法在mysql中为每个tradedate获得SUM(COUNTMINUS)和SUM(COUNTPLUS)的复杂性? Mayby由UDF?欢迎任何建议!致谢
我有以下表格数据:(这里我只限于一个TradeDate。但是其中有更多的TradeDates,一个包含Countplus数据,另一个包含Countminus数据。)
答案 0 :(得分:1)
我会尝试GROUP BY声明
SELECT TradeDate, SUM(market.Countminus) as Countminus, SUM(market.Countplus) as Countplus
FROM market
WHERE country = 'DE' and TradeDate = '2017-08-15'
GROUP BY TradeDate
答案 1 :(得分:0)
对不起我打扰你,但有一个总和功能:
SELECT TradeDate,sum(market.Countminus),sum(market.Countplus) from market where country = 'DE' and TradeDate = '2017-08-15 00:00:00' ;
谢谢,