Facebook
From Innocent Cockroach, 5 Years ago, written in Plain Text.
This paste is a reply to sql from sdada - go back
Embed
Viewing differences between sql and Re: sql
SELECT c.FirstName, c.LastName, g.Name FROM Customer c, Invoice i, InvoiceLine il, Track t, Genre g WHERE c.CustomerId=i.CustomerId AND i.InvoiceId=il.InvoiceId AND il.TrackId=t.TrackId AND t.GenreId=g.GenreId AND g.Name='Heavy Metal' AND c.Country='USA';     DROP TABLE IF EXISTS mdc_appdev_lifeflux.mdc_flx_events_procedures_icd;

       CREATE TABLE mdc_appdev_lifeflux.mdc_flx_events_procedures_icd
       PARTITIONED BY (internalpatientid)
       STORED AS PARQUET
       AS
        select insertDate, dateOfEvent, eventXML, internalpatientid
        from (
        SELECT 
                            now() insertDate, 
                            procedures_icd.startdate dateOfEvent, 
                            CONCAT
                            (
                            '                                 'Type="',  'procedures_icd', '" ',
                                'Alias="','procedures_icd', '" ',
                                'Age="', cast(procedures_icd.ageatevent as varchar(23)), '" ',
                                'Time="', cast(procedures_icd.startdate as varchar(23)), '">',
                                '',isnull(cast(procedures_icd.ageatevent as string),'Null'), '','',isnull(cast(procedures_icd.servicecode as string),'Null'), '','',isnull(cast(procedures_icd.insert_date as string),'Null'), '','',isnull(cast(procedures_icd.internalpatientid as string),'Null'), '','',isnull(cast(procedures_icd.startdate as string),'Null'), '','',isnull(cast(procedures_icd.sequencenumber as string),'Null'), '','',isnull(cast(procedures_icd.servicecodedesc as string),'Null'), '',
                            ''
                            ) eventXML,
                            procedures_icd.internalpatientid internalpatientId 
                        FROM
                            mimic_db.procedures_icd INNER JOIN mimic_db.demographics_static
                            ON (mimic_db.procedures_icd.internalpatientid=mimic_db.demographics_static.internalpatientid)    
        ) tbl;