0

mysql数据库

mysql查询:

SELECT * 
FROM allcoins 
WHERE creation_date > NOW() - INTERVAL 1 MINUTE 
  AND (status='hot') 
group by base 
having count(*) > 3 
CREATE TABLE `allcoins` (
  `ID` int(11) NOT NULL,
  `base` varchar(50) DEFAULT NULL,
  `quote_currency` varchar(50) DEFAULT NULL,
  `indic` varchar(50) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `laststatus` varchar(50) DEFAULT NULL,
  `creation_date` varchar(50) DEFAULT NULL,
  `prices` varchar(50) DEFAULT NULL,
  `indic_label` varchar(50) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `allcoins` (`ID`, `base`, `quote_currency`, `indic`, `status`, `laststatus`, `creation_date`, `prices`, `indic_label`) VALUES
(1, 'ICX', 'BTC', 'adx', 'hot', 'cold', '2020-09-02 15:10:45', '', 'adx 4h'),
(2, 'ICX', 'BTC', 'bbp', 'hot', 'cold', '2020-09-02 15:10:44', '', 'adx 1h'),
(4, 'ICX', 'BTC', 'stoch_rsi', 'hot', 'hot', '2020-09-02 15:10:42', '', 'adx 4h'),
(5, 'ICX', 'BTC', 'adx', 'cold', 'hot', '2020-09-02 15:10:41', '', 'adx 1h'),
(6, 'PIVX', 'BTC', 'adx', 'cold', 'cold', '2020-09-07 18:45:39', '', 'adx 4h'),
(7, 'IOST', 'BTC', 'ma_ribbon', 'hot', 'neutral', '2020-09-07 18:45:39', '', ''),
(8, 'IOST', 'BTC', 'bbp', 'cold', 'neutral', '2020-09-07 18:45:39', '', 'Bollinger 4 hr'),
(9, 'STEEM', 'BTC', 'adx', 'cold', 'cold', '2020-09-07 18:45:39', '', 'adx 1h'),
(10, 'NANO', 'BTC', 'adx', 'cold', 'cold', '2020-09-07 18:45:39', '', 'adx 1h'),
(11, 'VIA', 'BTC', 'bbp', 'hot', 'neutral', '2020-09-07 18:45:39', '', 'Bollinger 1H'),
(12, 'BLZ', 'BTC', 'adx', 'cold', 'cold', '2020-09-07 18:45:39', '', 'adx 1h'),
(13, 'BLZ', 'BTC', 'adx', 'cold', 'cold', '2020-09-07 18:45:39', '', 'adx 4h'),
(14, 'AE', 'BTC', 'adx', 'cold', 'cold', '2020-09-07 18:45:39', '', 'adx 1h'),
(15, 'POA', 'BTC', 'adx', 'cold', 'cold', '2020-09-07 18:45:39', '', 'adx 1h');

有了上面的信息,ICX 应该会和我们的请求一起显示。

我想在 30 秒内显示重复基列超过 3 次谢谢

4

1 回答 1

0

检查此查询是否是一个解决方案:

SELECT DISTINCT t1.base
FROM allcoins t1
JOIN allcoins t2 ON t1.base = t2.base 
                AND t1.creation_date < t2.creation_date
JOIN allcoins t3 ON t1.base = t3.base 
                AND t2.creation_date < t3.creation_date
                AND t1.creation_date >= t3.creation_date - INTERVAL 30 SECOND;

小提琴

于 2020-09-09T12:36:40.843 回答