0

我在一个表(客户)中有 3 列(CustomerId、Amount、ProcessDate)。

每天都会在此表中插入值。

我想获取当天金额大于前一天金额的所有行。

CustomerId 金额 Process_date

1 20 12/05/2021

2 30 2021 年 12 月 5 日

1 40 13/05/2021

2 25 13/05/2022

我们必须打印 (1 40 13/05/2021),因为 20(前一天的金额)小于 40(第二天的金额)。

我试过的查询:-

select b.customerId, b.amount, b.process_date from customer a
 join (select customerId, amount, process_date from customer where process_date = current_date ) as b
on
a.customerId = b.customerId and 
a.process_date = current_date - 1 and a.amount < b.amount
4

0 回答 0