Browsing:

Month: November 2024

NOT IN and NOT EXISTS

Scenario: Imagine you have two tables: students and enrollments. The students table contains all students, and the enrollments table contains the students who are enrolled in courses. We want to find out which students are not enrolled in any course. Read more…


SQL -problem -subscription

Source:https://www.interviewquery.com/questions/subscription-overlap Given a table of product subscriptions with a subscription start date and end date for each user, write a query that returns true or false whether or not each user has a subscription date range that overlaps with any Read more…


CROSS JOIN and UNION ALL

Let’s say you have the following table: user_id start_date end_date 1 2023-01-01 2023-01-10 2 2023-01-05 2023-01-15 3 2023-02-01 2023-02-10 Why CROSS JOIN? Why Not UNION ALL? Key Limitation: Alternative to CROSS JOIN (More Efficient Approach): If you want to avoid Read more…


palindrome number -Python

Steps to Reverse a Number: Here’s the code to check if a number is the same when reversed: