I have a table with Date, ID and Volume such as in below:
Date | ID | Volume |
---|---|---|
23/11/22 | 999 | 10 |
23/11/22 | 888 | 10 |
23/11/22 | 777 | 10 |
22/11/22 | 888 | 10 |
22/11/22 | 777 | 10 |
I would like the ID to appear in the ID column in 22/11/22 even though it manifested 0 volume and to create a flag such as below telling Day over Day (DoD) which ones are "Not Active":
Date | ID | Volume | Status |
---|---|---|---|
23/11/22 | 999 | 10 | Active |
23/11/22 | 888 | 10 | Active |
23/11/22 | 777 | 10 | Active |
22/11/22 | 999 | 0 | Inactive |
22/11/22 | 888 | 10 | Active |
22/11/22 | 777 | 10 | Active |
I attempted the following but return 0 rows and I do not know what to do next..
` select distinct csmp.date csmp.mcid as id ,count(*) as volume
from volume csmp
where id NOT IN
(select csmp.mcid
from calc.swa_manifested_packages csmp
GROUP BY csmp.mc
)
GROUP BY
csmp.mcid`
thank you all!