Skip to content

Commit

Permalink
Adjusting trades table logic
Browse files Browse the repository at this point in the history
  • Loading branch information
olgafetisova committed Jul 11, 2024
1 parent 90aceb8 commit dbd71d0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ valued_trades as (
WHEN sell_price IS NOT NULL THEN
-- Choose the larger of two prices when both not null.
CASE
WHEN buy_price IS NOT NULL and buy_price * units_bought > sell_price * units_sold
WHEN buy_price IS NOT NULL and buy_price * COALESCE(units_bought,0) > sell_price * COALESCE(units_sold,0)
then buy_price * units_bought
ELSE sell_price * units_sold
END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ valued_trades as (
WHEN sell_price IS NOT NULL THEN
-- Choose the larger of two prices when both not null.
CASE
WHEN buy_price IS NOT NULL and buy_price * units_bought > sell_price * units_sold
WHEN buy_price IS NOT NULL and buy_price * COALESCE(units_bought,0) > sell_price * COALESCE(units_sold,0)
then buy_price * units_bought
ELSE sell_price * units_sold
END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ valued_trades as (
WHEN sell_price IS NOT NULL THEN
-- Choose the larger of two prices when both not null.
CASE
WHEN buy_price IS NOT NULL and buy_price * units_bought > sell_price * units_sold
WHEN buy_price IS NOT NULL and buy_price * COALESCE(units_bought,0) > sell_price * COALESCE(units_sold,0)
then buy_price * units_bought
ELSE sell_price * units_sold
END
Expand Down

0 comments on commit dbd71d0

Please sign in to comment.