Skip to content

Commit 19502ab

Browse files
committed
replace the view transaction (steve-community#1219)
1 parent 14ba05f commit 19502ab

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/resources/db/migration/V1_0_5__update.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,21 @@ group by
1515
`o`.`expiry_date`,
1616
`o`.`max_active_transaction_count`,
1717
`o`.`note`;
18+
19+
CREATE OR REPLACE VIEW `transaction` AS
20+
SELECT
21+
tx1.transaction_pk,
22+
tx1.connector_pk,
23+
tx1.id_tag,
24+
tx1.event_timestamp as 'start_event_timestamp',
25+
tx1.start_timestamp,
26+
tx1.start_value,
27+
tx2.event_actor as 'stop_event_actor',
28+
tx2.event_timestamp as 'stop_event_timestamp',
29+
tx2.stop_timestamp,
30+
tx2.stop_value,
31+
tx2.stop_reason
32+
FROM transaction_start tx1
33+
LEFT JOIN transaction_stop tx2
34+
ON tx1.transaction_pk = tx2.transaction_pk
35+
AND tx2.event_timestamp = (SELECT MAX(event_timestamp) FROM transaction_stop s2 WHERE tx2.transaction_pk = s2.transaction_pk)

0 commit comments

Comments
 (0)