Skip to content

Commit

Permalink
✏️ fix: correct supply chain network sales and add data solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilbottom committed Jul 7, 2024
1 parent 195640d commit 2e54f50
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The solution can be found at:

- [supply-chain-network.md](../../solutions/gold/supply-chain-network.md)

A worked example is provided below to help illustrate the "shuffling" within the locations.
A worked example is provided below to help illustrate the stock movement within the locations.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ values
('2024-01-02 07:12:21'::timestamp, 6, 1001, 2),
('2024-01-02 09:51:01'::timestamp, 7, 1001, 4),
('2024-01-02 10:55:42'::timestamp, 8, 1001, 9),
('2024-01-02 11:21:10'::timestamp, 7, 1001, 19),
('2024-01-02 15:02:20'::timestamp, 7, 1001, 1),
('2024-01-02 16:18:00'::timestamp, 7, 1001, 1),
('2024-01-02 18:47:13'::timestamp, 7, 1001, 9),
('2024-01-02 11:21:10'::timestamp, 6, 1001, 19),
('2024-01-02 15:02:20'::timestamp, 6, 1001, 1),
('2024-01-02 16:18:00'::timestamp, 6, 1001, 1),
('2024-01-02 18:47:13'::timestamp, 6, 1001, 9),
('2024-01-02 19:15:12'::timestamp, 8, 1001, 5),
('2024-01-02 20:38:01'::timestamp, 6, 1001, 14),
('2024-01-03 07:00:27'::timestamp, 7, 1001, 13),
('2024-01-03 07:00:27'::timestamp, 6, 1001, 3),
('2024-01-03 08:56:40'::timestamp, 6, 1001, 1),
('2024-01-03 09:40:07'::timestamp, 6, 1001, 14),
('2024-01-03 09:40:07'::timestamp, 6, 1001, 4),
('2024-01-03 10:21:06'::timestamp, 7, 1001, 4),
('2024-01-03 12:31:10'::timestamp, 6, 1001, 10),
('2024-01-03 12:31:10'::timestamp, 7, 1001, 6),
('2024-01-03 15:56:56'::timestamp, 8, 1001, 5),
('2024-01-03 17:49:04'::timestamp, 7, 1001, 12),
('2024-01-03 18:02:34'::timestamp, 6, 1001, 1),
('2024-01-03 18:02:34'::timestamp, 6, 1001, 12),
('2024-01-03 20:19:42'::timestamp, 7, 1001, 7),
('2024-01-03 20:28:00'::timestamp, 6, 1001, 8),
('2024-01-03 20:28:00'::timestamp, 8, 1001, 15),
('2024-01-04 13:07:02'::timestamp, 7, 1001, 24),
('2024-01-04 14:03:39'::timestamp, 8, 1001, 16)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,32 @@

Regardless of the database, the result set should look like:

(to be added)
| stock_date | store_id | supplier_id | stock_volume | stock_proportion |
| :--------- | -------: | ----------: | -----------: | ---------------: |
| 2024-01-01 | 6 | 1 | 0 | 0.00 |
| 2024-01-01 | 6 | 2 | 10 | 100.00 |
| 2024-01-01 | 7 | 1 | 0 | 0.00 |
| 2024-01-01 | 7 | 2 | 0 | 0.00 |
| 2024-01-01 | 8 | 1 | 0 | 0.00 |
| 2024-01-01 | 8 | 2 | 0 | 0.00 |
| 2024-01-02 | 6 | 1 | 0 | 0.00 |
| 2024-01-02 | 6 | 2 | 9 | 100.00 |
| 2024-01-02 | 7 | 1 | 6 | 54.55 |
| 2024-01-02 | 7 | 2 | 5 | 45.45 |
| 2024-01-02 | 8 | 1 | 0 | 0.00 |
| 2024-01-02 | 8 | 2 | 1 | 100.00 |
| 2024-01-03 | 6 | 1 | 14 | 41.18 |
| 2024-01-03 | 6 | 2 | 20 | 58.82 |
| 2024-01-03 | 7 | 1 | 0 | 0.00 |
| 2024-01-03 | 7 | 2 | 2 | 100.00 |
| 2024-01-03 | 8 | 1 | 1 | 6.25 |
| 2024-01-03 | 8 | 2 | 15 | 93.75 |
| 2024-01-04 | 6 | 1 | 34 | 57.63 |
| 2024-01-04 | 6 | 2 | 25 | 42.37 |
| 2024-01-04 | 7 | 1 | 3 | 100.00 |
| 2024-01-04 | 7 | 2 | 0 | 0.00 |
| 2024-01-04 | 8 | 1 | 15 | 100.00 |
| 2024-01-04 | 8 | 2 | 0 | 0.00 |

<details>
<summary>Expand for the DDL</summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
```sql
solution(stock_date, store_id, supplier_id, stock_volume, stock_proportion) as (
values
('2024-01-01'::date, 6, 1, 0, 0.00),
('2024-01-01'::date, 6, 2, 10, 100.00),
('2024-01-01'::date, 7, 1, 0, 0.00),
('2024-01-01'::date, 7, 2, 0, 0.00),
('2024-01-01'::date, 8, 1, 0, 0.00),
('2024-01-01'::date, 8, 2, 0, 0.00),
('2024-01-02'::date, 6, 1, 0, 0.00),
('2024-01-02'::date, 6, 2, 9, 100.00),
('2024-01-02'::date, 7, 1, 6, 54.55),
('2024-01-02'::date, 7, 2, 5, 45.45),
('2024-01-02'::date, 8, 1, 0, 0.00),
('2024-01-02'::date, 8, 2, 1, 100.00),
('2024-01-03'::date, 6, 1, 14, 41.18),
('2024-01-03'::date, 6, 2, 20, 58.82),
('2024-01-03'::date, 7, 1, 0, 0.00),
('2024-01-03'::date, 7, 2, 2, 100.00),
('2024-01-03'::date, 8, 1, 1, 6.25),
('2024-01-03'::date, 8, 2, 15, 93.75),
('2024-01-04'::date, 6, 1, 34, 57.63),
('2024-01-04'::date, 6, 2, 25, 42.37),
('2024-01-04'::date, 7, 1, 3, 100.00),
('2024-01-04'::date, 7, 2, 0, 0.00),
('2024-01-04'::date, 8, 1, 15, 100.00),
('2024-01-04'::date, 8, 2, 0, 0.00)
)
```

0 comments on commit 2e54f50

Please sign in to comment.