DBMS:
sqlite

Error:
table cov_1 already exists

SQL:
CREATE TEMP TABLE cov_1
AS
SELECT
CAST(drug_concept_id AS BIGINT) * 1000 + 301 AS covariate_id,
    time_id,
	row_id,
	1 AS covariate_value 
FROM
(
	SELECT DISTINCT drug_concept_id,
		time_id,
		cohort.subject_id AS row_id
	FROM main.cohort cohort
	INNER JOIN main.drug_exposure
		ON cohort.subject_id = drug_exposure.person_id
	INNER JOIN temp.time_period time_period
		ON drug_exposure_start_date <= CAST(STRFTIME('%s', DATETIME(cohort.cohort_start_date, 'unixepoch', (time_period.end_day)||' days')) AS REAL)
		AND drug_exposure_start_date >= CAST(STRFTIME('%s', DATETIME(cohort.cohort_start_date, 'unixepoch', (time_period.start_day)||' days')) AS REAL)
	WHERE drug_concept_id != 0
		AND cohort.cohort_definition_id IN (1)
) by_row_id


R version:
R version 4.3.3 (2024-02-29)

Platform:
aarch64-apple-darwin20

Attached base packages:
- stats
- graphics
- grDevices
- utils
- datasets
- methods
- base

Other attached packages:
- FeatureExtraction (3.7.1)
- Andromeda (0.6.6)
- dplyr (1.1.4)
- DatabaseConnector (6.3.2)
- testthat (3.2.1)