Skip to content

Commit

Permalink
break ties for qn: Which customer made the highest number of transact…
Browse files Browse the repository at this point in the history
…ions in the same month as they signed up?
  • Loading branch information
wendy-aw authored and wongjingping committed Aug 14, 2024
1 parent cde7f15 commit 74b8988
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions defog_data/broker/broker.sql
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,15 @@ INSERT INTO sbTransaction (sbTxId, sbTxCustId, sbTxTickerId, sbTxDateTime, sbTxT
('TX042', 'C003', 'T013', NOW() - INTERVAL '8 days', 'buy', 80, 180.00, 14400.00, 'USD', 72.00, 10.00, 'KP042', TO_CHAR(NOW() - INTERVAL '8 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX043', 'C004', 'T014', NOW() - INTERVAL '7 days', 'sell', 60, 220.00, 13200.00, 'USD', 66.00, 12.00, 'KP043', NULL, 'pending'),
('TX044', 'C012', 'T001', '2023-01-15 10:00:00', 'buy', 80, 155.00, 12400.00, 'USD', 62.00, 10.00, 'KP044', '20230115 10:00:00', 'success'),
('TX045', 'C013', 'T002', '2023-02-20 11:30:00', 'sell', 60, 285.00, 17100.00, 'USD', 85.50, 15.00, 'KP045', '20230220 11:30:00', 'success'),
('TX046', 'C014', 'T003', '2023-03-25 14:45:00', 'buy', 5, 3250.00, 16250.00, 'USD', 81.25, 20.00, 'KP046', '20230325 14:45:00', 'success'),
('TX047', 'C012', 'T004', '2023-01-30 13:15:00', 'sell', 40, 190.00, 7600.00, 'USD', 38.00, 10.00, 'KP047', '20230130 13:15:00', 'success'),
('TX048', 'C013', 'T005', '2023-02-28 16:00:00', 'buy', 2, 2550.00, 5100.00, 'USD', 25.50, 15.00, 'KP048', '20230228 16:00:00', 'success'),
('TX049', 'C014', 'T006', '2023-03-30 09:45:00', 'sell', 30, 210.00, 6300.00, 'USD', 31.50, 10.00, 'KP049', '20230331 09:45:00', 'success'),
('TX050', 'C015', 'T001', DATE_TRUNC('month', NOW()) - INTERVAL '5 months' + INTERVAL '1 day', 'buy', 50, 150.00, 7500.00, 'USD', 37.50, 10.00, 'KP050', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '5 months' + INTERVAL '1 day', '%Y%m%d %H:%i:%s'), 'success'),
('TX051', 'C016', 'T002', DATE_TRUNC('month', NOW()) - INTERVAL '4 months' + INTERVAL '2 days', 'sell', 40, 280.00, 11200.00, 'USD', 56.00, 10.00, 'KP051', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '4 months' + INTERVAL '2 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX052', 'C017', 'T003', DATE_TRUNC('month', NOW()) - INTERVAL '3 months' + INTERVAL '3 days', 'buy', 15, 3200.00, 48000.00, 'USD', 240.00, 20.00, 'KP052', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '3 months' + INTERVAL '3 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX053', 'C018', 'T004', DATE_TRUNC('month', NOW()) - INTERVAL '2 months' + INTERVAL '4 days', 'sell', 30, 180.00, 5400.00, 'USD', 27.00, 5.00, 'KP053', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '2 months' + INTERVAL '4 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX054', 'C019', 'T005', DATE_TRUNC('month', NOW()) - INTERVAL '1 month' + INTERVAL '5 days', 'buy', 10, 2500.00, 25000.00, 'USD', 125.00, 15.00, 'KP054', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '1 month' + INTERVAL '5 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX055', 'C002', 'T006', DATE_TRUNC('month', NOW()) + INTERVAL '1 day', 'sell', 20, 200.00, 4000.00, 'USD', 20.00, 10.00, 'KP055', TO_CHAR(DATE_TRUNC('month', NOW()) + INTERVAL '1 day', '%Y%m%d %H:%i:%s'), 'success');
('TX045', 'C012', 'T001', '2023-01-16 10:30:00', 'buy', 80, 155.00, 12400.00, 'USD', 62.00, 10.00, 'KP045', '20230116 10:30:00', 'success'),
('TX046', 'C013', 'T002', '2023-02-20 11:30:00', 'sell', 60, 285.00, 17100.00, 'USD', 85.50, 15.00, 'KP046', '20230220 11:30:00', 'success'),
('TX047', 'C014', 'T003', '2023-03-25 14:45:00', 'buy', 5, 3250.00, 16250.00, 'USD', 81.25, 20.00, 'KP047', '20230325 14:45:00', 'success'),
('TX048', 'C012', 'T004', '2023-01-30 13:15:00', 'sell', 40, 190.00, 7600.00, 'USD', 38.00, 10.00, 'KP048', '20230130 13:15:00', 'success'),
('TX049', 'C013', 'T005', '2023-02-28 16:00:00', 'buy', 2, 2550.00, 5100.00, 'USD', 25.50, 15.00, 'KP049', '20230228 16:00:00', 'success'),
('TX050', 'C014', 'T006', '2023-03-30 09:45:00', 'sell', 30, 210.00, 6300.00, 'USD', 31.50, 10.00, 'KP050', '20230331 09:45:00', 'success'),
('TX051', 'C015', 'T001', DATE_TRUNC('month', NOW()) - INTERVAL '5 months' + INTERVAL '1 day', 'buy', 50, 150.00, 7500.00, 'USD', 37.50, 10.00, 'KP051', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '5 months' + INTERVAL '1 day', '%Y%m%d %H:%i:%s'), 'success'),
('TX052', 'C016', 'T002', DATE_TRUNC('month', NOW()) - INTERVAL '4 months' + INTERVAL '2 days', 'sell', 40, 280.00, 11200.00, 'USD', 56.00, 10.00, 'KP052', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '4 months' + INTERVAL '2 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX053', 'C017', 'T003', DATE_TRUNC('month', NOW()) - INTERVAL '3 months' + INTERVAL '3 days', 'buy', 15, 3200.00, 48000.00, 'USD', 240.00, 20.00, 'KP053', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '3 months' + INTERVAL '3 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX054', 'C018', 'T004', DATE_TRUNC('month', NOW()) - INTERVAL '2 months' + INTERVAL '4 days', 'sell', 30, 180.00, 5400.00, 'USD', 27.00, 5.00, 'KP054', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '2 months' + INTERVAL '4 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX055', 'C019', 'T005', DATE_TRUNC('month', NOW()) - INTERVAL '1 month' + INTERVAL '5 days', 'buy', 10, 2500.00, 25000.00, 'USD', 125.00, 15.00, 'KP055', TO_CHAR(DATE_TRUNC('month', NOW()) - INTERVAL '1 month' + INTERVAL '5 days', '%Y%m%d %H:%i:%s'), 'success'),
('TX056', 'C002', 'T006', DATE_TRUNC('month', NOW()) + INTERVAL '1 day', 'sell', 20, 200.00, 4000.00, 'USD', 20.00, 10.00, 'KP056', TO_CHAR(DATE_TRUNC('month', NOW()) + INTERVAL '1 day', '%Y%m%d %H:%i:%s'), 'success');

0 comments on commit 74b8988

Please sign in to comment.