0

Am getting an error that goes like this:
Insert values statement can contain only constant literal values or variable references.

these are the statements in which I am getting the errors:

INSERT INTO val.summary_numbers (metric_name, metric_val, dt_create) VALUES ('Total IP Enconters',
                                                                             (SELECT
                                                                                count(DISTINCT encounter_id)
                                                                              FROM prod.encounter
                                                                              WHERE encounter_type = 'Inpatient')

                                                                             ,
                                                                                (SELECT min(mod_loadidentifier)
                                                                                 FROM ccsm.stg_demographics_baseline)

                                                                             );


INSERT INTO val.summary_numbers (metric_name, metric_val, dt_create) VALUES ('Total 30d Readmits',
                                                                  (SELECT
                                                                     count(DISTINCT encounter_id)
                                                                   FROM prod.encounter_attr
                                                                   WHERE
                                                                     attr_name = 'day_30_readmit' AND attr_value = 1)

                                                                  ,
                                                                     (SELECT min(mod_loadidentifier)
                                                                      FROM ccsm.stg_demographics_baseline));

2 Answers 2

2

Change your query like this:

insert into val.summary_numbers
select
        'Total IP Enconters',
        (select  count(distinct encounter_id)
         from    prod.encounter
         where   encounter_type = 'Inpatient'),
        (select  min(mod_loadidentifier)
         from    ccsm.stg_demographics_baseline)
Sign up to request clarification or add additional context in comments.

2 Comments

When am using the above am getting parsing error near from statement
@DeadMan fixed a paren. Try again
0

When using the ADW service, I would recommend that you consider using the CTAS operation possibly combined with a RENAME. The RENAME is a metadata operation so it is fast and the CTAS is parallel where the INSERT INTO will be row by row.

You may still have a data related issue that can be hard to determine with out the create table statement.

Thanks

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.