Writing a query to select user_ids based on allocation date:
below are the parameters I am using.
allocation start date
allocation end date
from date
to date
The below query is failing to get a result
SELECT
DISTINCT user_id
FROM
table_name
WHERE
from_date <= allocation_start_date
AND to_date>=allocation_end_date
example:
user_id allocation start date allocation end
1 2022-08-10 2022-10-10
2 2022-05-01 2022-06-30
3 2022-05-01 2022-09-10
4 2022-05-01 2022-05-11
if I give from date as 2022-05-01 and to date as 2022-07-30
I should get user ids 2 and 4.
please help, not able to figure out this.
Thank you in advance.
2022-05-01is just an integer expression with the value2016. Show us your code. - Tim Roberts