i have transaction table :
| id | user_id | value | status |datetime |
|:—-: |:——:| :—–:|:—-:|:—-:|
| 1 | 1 | 10000|true|2024-06-22 00:21:00|
| 2 | 1 | 10000|false|2024-06-22 00:22:00|
| 3 | 2 | 11000|false|2024-06-26 00:15:00|
| 4 | 1 | 11000|true|2024-06-28 00:21:28|
| 5 | 3 | 12000|true|2024-06-28 00:21:28|
| 6 | 3 | 13000|true|2024-06-28 00:25:28|
| 7 | 1 | 13000|true|2024-06-28 00:25:28|
i want reach 2 result from that table
first, get sum of value from first data of each user_id where status is true
the view table is like this:
| id | user_id | value | status |datetime |
|:—-: |:——:| :—–:|:—-:|:—-:|
| 1 | 1 | 10000|true|2024-06-22 00:21:00|
| 5 | 3 | 12000|true|2024-06-28 00:21:28|
i want sum that result row, so the sum is
22000
second, get sum from first data of each user_id where status true and datetime like 2024-06-28
| id | user_id | value | status |datetime |
|:—-: |:——:| :—–:|:—-:|:—-:|
| 4 | 1 | 11000|true|2024-06-28 00:21:28|
| 5 | 3 | 12000|true|2024-06-28 00:21:28|
sum value is
23000