question: Importance: As the COVID-19 pandemic continues, understanding the clinical outcomes of patients with cancer and COVID-19 has become critically important. Objective: To compare the outcomes of patients with or without cancer who were diagnosed with COVID-19 and to identify the factors associated with mortality, mechanical ventilation, intensive care unit (ICU) stay, and hospitalization. Design, Setting, and Participants: This cohort study obtained data from the Optum de-identified COVID-19 electronic health record data set. More than 500â¯000 US adults who were diagnosed with COVID-19 from January 1 to December 31, 2020, were analyzed. Exposures: The patient groups were (1) patients without cancer, (2) patients with no recent cancer treatment, and (3) patients with recent cancer treatment (within 3 months before COVID-19 diagnosis) consisting of radiation therapy or systemic therapy. Main Outcomes and Measures: Mortality, mechanical ventilation, ICU stay, and hospitalization within 30 days of COVID-19 diagnosis were the main outcomes. Unadjusted rates and adjusted odds ratios (ORs) of adverse outcomes were presented according to exposure group. Results: A total of 507â¯307 patients with COVID-19 were identified (mean [SD] age, 48.4 [18.4] years; 281 165 women [55.4%]), of whom 493â¯020 (97.2%) did not have cancer. Among the 14â¯287 (2.8%) patients with cancer, 9991 (69.9%) did not receive recent treatment and 4296 (30.1%) received recent treatment. In unadjusted analyses, patients with cancer, regardless of recent treatment received, were more likely to have adverse outcomes compared with patients without cancer (eg, mortality rate: 1.6% for patients without cancer, 5.0% for patients with no recent cancer treatment, and 7.8% for patients with recent cancer treatment). After adjustment, patients with no recent cancer treatment had similar or better outcomes than patients without cancer (eg, mortality OR, 0.93 [95% CI, 0.84-1.02]; mechanical ventilation OR, 0.61 [95% CI, 0.54-0.68]). In contrast, a higher risk of death (OR, 1.74; 95% CI, 1.54-1.96), ICU stay (OR, 1.69; 95% CI, 1.54-1.87), and hospitalization (OR, 1.19; 95% CI, 1.11-1.27) was observed in patients with recent cancer treatment. Compared with patients with nonmetastatic solid tumors, those with metastatic solid tumors and hematologic malignant neoplasms had worse outcomes (eg, mortality OR, 2.36 [95% CI, 1.96-2.84]; mechanical ventilation OR, 0.87 [95% CI, 0.70-1.08]). Recent chemotherapy and chemoimmunotherapy were also associated with worse outcomes (eg, chemotherapy mortality OR, 1.84 [95% CI, 1.51-2.26]). Conclusions and Relevance: This cohort study found that patients with recent cancer treatment and COVID-19 had a significantly higher risk of adverse outcomes, and patients with no recent cancer treatment had similar outcomes to those without cancer. The findings have risk stratification and resource use implications for patients, clinicians, and health systems.