New to SQL and need to write a query

  • Hello all

     

    I am new to using SQL and was asked to write a query. I was told what tables I needed and also the keys for joins. Unfortunately it doesn't make sense to me. I am attaching an excel workbook that has two tabs. The first tabs are the tables and their content, and the second tab is the the keys for jins. Can anyone help me create this query? Any assistance would be greatly appreciated.

     

    Thanks

    Attachments:
    You must be logged in to view attached files.
  • My apologies...I should have said I basically just need to know how the tables are joined. I am trying to

    • Goal: Race/Ethnicity distribution by Payers

    • Measures: Patient (MRN or PatientID) Count and Encounter (PatientEncounterID) Count

    • Time period: FY19-FY20 Q1 (From Oct-2018 to Mar-2020)

  • Getting tossed into the deep end. I feel for you. I'll try to help.

    Strong recommendation, take some time and spend it reading. The Stairways series on T-SQL would be a great place to start. I've also got a series of blog posts on SQL Server Fundamentals that might be useful.

    However, you have some other issues. The key on Epic.Finance.HospitalAccount is PatientMRN and CoverageID. I don't see either of those in SharedLocal.Person.PatientExtension. I only see CoverageID in the other two tables. From what I can tell, there's not a way to join that table to the other ones. Nor is the PatientExtension key in the HospitalAccount table. That means we can't go the other way, joining PatientExtension to Hospitalccount.

    In fact, the only two tables I can see a way to join are the last two: Epic.Finance.Coverage and Epic.Reference.Payor

    SELECT *
    FROM Epic.Finance.Coverage AS efc
    JOIN Epic.Reference.Payer AS erp
    ON efc.PayerID = erp.PayerID

    Not much help, but I think you need to go back and get better definitions from someone.

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply