我有下面两个表格。一种是存储收到的资产数据,另一种是当客户代表联系时。
Asset_Data_Historical
+---------+------------------+
| AssetID | Data_Received_On |
+---------+------------------+
| 17085 | 8/23/2017 22:50 |
| 17085 | 8/25/2017 20:54 |
| 17085 | 8/25/2017 21:08 |
| 17085 | 8/31/2017 18:49 |
| 17085 | 9/29/2017 18:51 |
+---------+------------------+
Customer_Contacted_Logs
+----------+----------+-------------------+
| TicketID | Asset_ID | Last_Contacted_On |
+----------+----------+-------------------+
| 1785487 | 17085 | 9/28/2017 21:57 |
| 1785491 | 17085 | 10/16/2017 18:51 |
+----------+----------+-------------------+
我的问题是: 我需要根据Asset_data_Historical表从Customer_Contacted_Logs中查找数据。
例如:对于AssetID 17085,在8/23/2017 22:50收到的第一个数据。现在,查询必须在Customer_Contacted_Logs中查找数据“ Last_Contacted_on”,该数据等于但大于或等于下一个Received_On数据。
因此,在这种情况下,将于8/23/2017 22:50接收到第一个数据,它将在Customer_contacted_log中查找数据,发现日期为9/28/2017 21:57,并且相同的日期将为由于“联系日期”不大于Data_Received_on而填充。在下一个实例中,它将获取日期10/16/2017 18:51。
这是一个示例,我希望如何获取查询。
+---------+------------------+-------------------+
| AssetID | Data_Received_On | Last_Contacted_On |
+---------+------------------+-------------------+
| 17085 | 8/23/2017 22:50 | 9/28/2017 21:57 |
| 17085 | 8/25/2017 20:54 | 9/28/2017 21:57 |
| 17085 | 8/25/2017 21:08 | 9/28/2017 21:57 |
| 17085 | 8/31/2017 18:49 | 9/28/2017 21:57 |
| 17085 | 9/29/2017 18:51 | 10/16/2017 18:51 |
+---------+------------------+-------------------+
如有任何疑问,请通知我。
先谢谢您
答案 0 :(得分:1)
您可以使用@PostMapping(path = "/payment/{unique_transaction_id}", consumes = "application/json", produces = "application/json")
correlated subquery