【发布时间】:2020-10-30 22:54:29
【问题描述】:
在下面你可以看到我的表格的一个例子:
test_id test_date test_date_from cash_per_step
1 2020-01-01 2019-12-30 30
1 2020-01-21 2019-12-30 40
1 2020-02-28 2019-12-30 30
2 2020-01-01 2019-12-30 30
2 2020-01-21 2019-12-30 40
2 2020-02-28 2019-12-30 30
如您所见,没有唯一的 ID(很遗憾我也无法更改)。 我想创建一个视图,该视图仅包含每个 test_id 的每个 MONTH 包含 MAX (test_date) 的行!
像这样:
test_id test_date test_date_from cash_per_step
1 2020-01-21 2019-12-30 40
1 2020-02-28 2019-12-30 30
2 2020-01-21 2019-12-30 40
2 2020-02-28 2019-12-30 30
数据仅为测试数据,请见谅。我只对查询的功能感兴趣。
【问题讨论】:
-
MySQL 还是 SQL Server?它们是完全不同的产品......
标签: mysql sql sql-server tsql denodo