SQL Joins Made VERY SIMPLE!

Поделиться
HTML-код
  • Опубликовано: 13 июл 2023
  • Whether you're a data analyst, data scientist, or data engineer, it's vital to understand how joins work in SQL, as it's foundational to how databases work!
    Watch this video as I explain the core concepts using healthcare data! Part 1 in a series of 3 videos:
    Video 1: SQL Joins
    Video 2: SQL Cardinality
    Video 3: SQL + Tableau Portfolio Project
    If you would like to follow along using the fake patient data I'm using,
    1. Go to www.datawizardry.academy
    2. Find SQL Basics in Healthcare
    3. Fill out info to get an email of the files
    I have a previous video where I walk you through how to Install SQL, and import those files:
    • 👉 SQL Basics with Heal...
    // BECOME A CLINICAL DATA ANALYST!
    My course teaches you everything you need to know in just 10-12 weeks:
    datawizardry.academy/clinical...
    // FREE WEBINAR!
    In this 1-hour webinar, I lay out a roadmap for you to learn how to become a data analyst, and gain healthcare domain knowledge:
    datawizardry.easywebinar.live...
    #dataanalyst #sql #dataanalytics #data #healthcaretechnology
  • НаукаНаука

Комментарии • 11

  • @osoriomatucurane9511
    @osoriomatucurane9511 16 дней назад

    Absolutely Awesome tutorial on join operations extended to filter.
    Thank you for highlighting the impact of cardinality on the size of the result set.
    I am left to understand the case use or when to decide to change the cardinality when performing the join, as displayed with the cte on the data wizardry web site under the sql basics healthcare

  • @joeltorres1237
    @joeltorres1237 Год назад +2

    Wow! this looks like a great project! Especially being able to combine sql with a viz tool.

  • @konata_fan
    @konata_fan Год назад +1

    So useful, thanks👍

  • @nithinanthony1724
    @nithinanthony1724 Год назад +2

    Nice one Sir

  • @drnamita9670
    @drnamita9670 9 месяцев назад

    Awesome videos.

  • @xavierwood6128
    @xavierwood6128 Год назад +2

    First of all, this video and your previous 60 min. video were amazing! The explanations are concise and the examples are easy to follow! I had a question regarding your example of including the "pat.first = 'Adelina'" in the inner join statement. I tried using "where pat.first = 'Adelina' " after the join statement and I got the same result of 34 rows returned. Do you think one approach is better than the other, or would it just be a preference?
    Thank you for all of your work in making videos!

    • @DataWizardry
      @DataWizardry  Год назад +2

      Great question!
      What's nice about SQL is that there's often multiple ways to achieve the same result. So, when I am faced with two different methods of achieving the same result, I go with the option that's easier to understand.
      So if I were tasked with looking up all patients named, Adelina, that had vaccines, my preferred way of writing it out would actually be:
      SELECT pat.id,
      pat.first,
      pat.last,
      imm.description,
      imm.patient
      FROM patients as pat
      INNER JOIN immunizations as imm
      on pat.id = imm.patient
      WHERE pat.first = 'Adelina'
      For me, it's just cleaner this way. Rather than the example in my tutorial where I used pat.first = 'Adelina' as a second condition in the join statement. Something about that approach just takes me a little longer to process what's happening. Whereas the above code is much more straight-forward.
      Making code as easy to understand as possible is a good habit to get into if you ever had to return to your work months later. (And your co-workers that might inherit the code, will appreciate you too!)

    • @xavierwood6128
      @xavierwood6128 Год назад +2

      @@DataWizardry I appreciate the in-depth answer! I also find the "WHERE" method to be easier to digest, so we're on the same page there. Thanks once again and I'm looking forward to your next videos!

  • @joeltorres1237
    @joeltorres1237 Год назад +1

    What was tripping me up was that patients table has only one Adelina Simonis for example and yet with left join on immunizations table I'm getting 10 instances of Adelina Simonis. Is this what you mean by a one to many? Bc there's many rows of that matching ID in immunizations table. It was a great lesson. And I like how you give a quick intro into what's next.

    • @DataWizardry
      @DataWizardry  Год назад +1

      Great question! Yes, this is a one to many. And we'll be looking at this in the next video I will be publishing which is on cardinality.
      But yes, you are correct. The patient Adelina Simonis shows up once in the patient table. And 10 ten times in the immunizations table (had a stretch of 10 annual flu shots from 1974-1983).
      When the one to many join happens, some of the information starts to repeat itself however many number of times there was a match in the other table. In this case, ten rows are created to show each of those flu shots that she received. Though, the patient informaiton remains the same so it gets duplicated.
      This query should help visualize that a little bit better:
      SELECT pat.id,
      pat.first,
      pat.last,
      imm.description,
      imm.patient,
      imm.date as immunization_given
      FROM patients as pat
      INNER JOIN immunizations as imm
      on pat.id = imm.patient
      WHERE pat.id = 'e398337a-523b-fbed-1dc9-f308588869d1'

  • @karthikswamy8848
    @karthikswamy8848 8 месяцев назад

    Hi , I am a pediatric Anesthesiologist .
    I have a lot of questions - can I have ur email id so that I can connnect with u.
    Thanks