gpt4 book ai didi

mysql - 如何在mySQL中选择近月到期

转载 作者:行者123 更新时间:2023-11-29 17:47:11 25 4
gpt4 key购买 nike

Date    Expiry  Close
20-Mar-18 28-Mar-18 10143.2
20-Mar-18 26-Apr-18 10180.2
20-Mar-18 31-May-18 10201
21-Mar-18 28-Mar-18 10180.2
21-Mar-18 26-Apr-18 10218.3
21-Mar-18 31-May-18 10237.8
22-Mar-18 28-Mar-18 10127.8
22-Mar-18 26-Apr-18 10168.8
22-Mar-18 31-May-18 10193.2
23-Mar-18 28-Mar-18 10003.9
23-Mar-18 26-Apr-18 10047.6
23-Mar-18 31-May-18 10060.2
26-Mar-18 28-Mar-18 10146.2
26-Mar-18 26-Apr-18 10178.3
26-Mar-18 31-May-18 10205
27-Mar-18 28-Mar-18 10179
27-Mar-18 26-Apr-18 10215.8
27-Mar-18 31-May-18 10235.2
28-Mar-18 28-Mar-18 10120.2
28-Mar-18 26-Apr-18 10152
28-Mar-18 31-May-18 10175.3
2-Apr-18 28-Jun-18 10301.4
2-Apr-18 31-May-18 10288.2
2-Apr-18 26-Apr-18 10264
3-Apr-18 26-Apr-18 10285
3-Apr-18 31-May-18 10313.9
3-Apr-18 28-Jun-18 10327.4
4-Apr-18 26-Apr-18 10146.6
4-Apr-18 31-May-18 10175.5
4-Apr-18 28-Jun-18 10194.7
5-Apr-18 26-Apr-18 10352.2
5-Apr-18 31-May-18 10381
5-Apr-18 28-Jun-18 10398
6-Apr-18 28-Jun-18 10399.3
6-Apr-18 31-May-18 10385.1
6-Apr-18 26-Apr-18 10352.8

第一列中的每个日期都有 3 个与其关联的到期日期。我想仅获取最接近日期的到期日(近一个月到期)的日期、关闭、到期日。我该怎么做?谢谢。

例如,我想要的结果是:

Date    Expiry  Close
20-Mar-18 28-Mar-18 10143.2
21-Mar-18 28-Mar-18 10180.2
22-Mar-18 28-Mar-18 10127.8
23-Mar-18 28-Mar-18 10003.9
26-Mar-18 28-Mar-18 10146.2
27-Mar-18 28-Mar-18 10179
28-Mar-18 28-Mar-18 10120.2
2-Apr-18 26-Apr-18 10264
3-Apr-18 26-Apr-18 10285
4-Apr-18 26-Apr-18 10146.6
5-Apr-18 26-Apr-18 10352.2
6-Apr-18 26-Apr-18 10352.8

最佳答案

还没有测试过,我认为在 MariaDB 中这是可行的。请尝试这个:

SELECT
Date,
Expiry,
Close
FROM
table
GROUP BY
Date
ORDER BY
Expiry DESC

关于mysql - 如何在mySQL中选择近月到期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49708592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com