ITWorks InfoTech interview question

Basic Python and SQL Queries related to Joints