SQL Cumulative project

Hi Codecademy,

Firstly, I apologize for not pasting a link to my code but the copy link button was not working. I hope it works tomorrow. (It just stayed on “…” forever and I could never copy the link)

I am working on the SQL cumulative project in the Data Science Path (the cholesterol exercise). I do not understand any of this code:

WITH total_active AS
(SELECT COUNT(ID) AS active FROM active_patients),
total_inactive AS
(SELECT COUNT(ID) AS inactive FROM inactive_patients),
total_patients AS
(SELECT total_active.active + total_inactive.inactive AS total FROM total_active, total_inactive)
(total_active.active100 / total_patients.total) AS percent_active,
100 / total_patients.total) AS percent_inactive
FROM total_active, total_inactive, total_patients;

I dont remember any of these concepts being taught. Could you please provide more links that can help me put this together- Especially how the variable names are set up, and referenced later in the equation. I understand the math, just not the logic of how the formulas are set up.



Most (if not all) of this is covered in this course: Learn SQL
This course gives a good background to SQL knowledge.

Hey, thanks. I did that course, I guess I need to review the last few modules to see the associations between the tables.