Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Find the overlap group through Inner Join for specific dates

I’m new to SQL so appreciate any help on this. I’ve been using an inner join and where clause to get all the unique Jedi who were active for 3 months in the Republic Area (Republic Table) and then determine how many of these Jedi were part of the Rebel Alliance (Rebel Table).

My query does execute but the data make me doubt I’m doing it right. Thank you for your help on this.

SELECT COUNT (DISTINCT republic.jedi_id)
FROM republic
INNER JOIN rebel ON republic.jedi_id = rebel.jedi_id
WHERE republic.date>='2020-01-01' AND republic.date <='2020-03-31'

Sample Data

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Query is pretty much correct.
Distinct is needed if there are than one Jedi with same name is any of the table.

SELECT COUNT republic.jedi_id
FROM republic
INNER JOIN rebel ON republic.jedi_id = rebel.jedi_id
WHERE republic.date>='2020-01-01' AND republic.date <='2020-03-31'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading