简体   繁体   中英

How can I search this on MySQL?

Every day the cron insert on data_log.table the logs of all coins.

I use the API from coinmarketcap.

API Documentation: https://coinmarketcap.com/api

I have a lot of duplicates with the Cryptocurrency names.

The challenge is to search between 2018-02-11 and 2018-02-18 to find a coin in this period triple who your market cap or your volume.

I want to search all the coins with one expression on mySQL.

My API Consult: http://127.0.0.1/db.php?json=data_log&startdate=2018-02-12&finaldate=2018-02-17

How can I do this?

I don't want to search one specific coin, I want to search all coins in this period got a triple of your value.

This is the structure:

 `data_log`(`id`, `moeda`, `moeda_simbolo`, `market_cap`, `volume`, 
            `data_cadastro`, `percent_change_1h`, `percent_change_24h`, 
            `percent_change_7d`, `price_usd`) 
  VALUES   (1, 'Bitcoin', 'BTC', '134001640106', '6628000000.0', 
            '2018-02-11', '-1.07', '-10.47', 
            '-11.75', '7948.84')

Example of storage:

(1313, 'Kubera Coin', 'KBR', '1807270.0', '155830.0', '2018-02-11', '-2.27', '-16.9', '-7.76', '0.0157946'),
(1314, 'Renos', 'RNS', '1788409.0', '2235.62', '2018-02-11', '2.0', '-3.49', '-4.48', '0.0536157'),
(1315, 'FujiCoin', 'FJC', '1786980.0', '2300.57', '2018-02-11', '4.67', '-2.84', '-23.1', '0.00137009'),
(1316, 'Bankcoin', 'B@', '1780694.0', '2679.29', '2018-02-11', '3.32', '348.87', '72.86', '0.173021'),
  1. You have dates in the log without an hour. If you want to increase the detail, then you will have a problem.

  2. To achieve what you want, you must sum up the values from the given date range and compare them to the values from the beginning of the period.

     SELECT * FROM (SELECT moeda, sum(market_cap) as sum_cap, sum(volume) AS sum_volume FROM data_log WHERE data_cadastro >= '2018-02-11' AND data_cadastro <= '2018-02-18' GROUP BY moeda) AS sum_log LEFT JOIN (SELECT * FROM data_log WHERE data_cadastro = '2018-02-11') AS dl ON dl.moeda = sum_log.moeda WHERE (sum_cap - market_cap) / 3 > market_cap OR (sum_volume - volume) / 3 > volume; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM