I am working with MS SQL server and I am trying to build a complex query with ecto which contains a CTE:
WITH
timeslots AS
(
SELECT cast('2021-01-09T00:00:00' as smalldatetime) as slot
UNION ALL
SELECT dateadd(minute , 1, slot)
FROM timeslots
WHERE dateadd(minute, 1, slot) < '2021-01-15T00:00:00'
),
After reading the documentation for CTE with Ecto, I was trying to build the “initial query” but I did not get far.
Indeed, I do not see how I can select a value not coming from a table (e.g.: SELECT cast('2021-01-09T00:00:00' as smalldatetime) as slot
).
Is there a way to do that without using fragments?