Questions tagged [recursive]
Using recursion to solve database problems.
263 questions
0 votes
2 answers
129 views
SSMS Noob Error: The query references an object that is not supported in distributed processing mode
I'm new to SQL and am trying to query a view (dbo.) made from a D365 table. My goal is to do a recursive joins on 4 different views but to start with I tried something basic and received the following ...
1 vote
1 answer
105 views
How to adapt a recursive CTE over multiple tables?
I'm using PostgreSQL 17 I am modelling a package index for the Haskell ecosystem, and a feature that is useful is to determine transitive dependencies. Haskell packages can be normalised as: Package ...
0 votes
1 answer
36 views
How to fuzzy query a directory structure in PostgreSQL?
I was able to put together a rough idea for a PostgreSQL query to query over a node table, which contains id, parent__id, slug, and file_url (optional). It's considered a file if it has file_url, ...
0 votes
1 answer
238 views
PostgreSQL CTE Recursion - How to Improve Performance for Parent->Child Tree (8 levels deep, 890 roots)
I am working on a query that performs PostgreSQL CTE Recursion in PostgreSQL 13. This query is intended to recurse from the root nodes to the deepest leaf node with certain properties (labeled 'begat'...
0 votes
1 answer
93 views
Designing a data model to handle both recurrence and nested dependencies
I'm building a web application that involves both recurrence and nested dependencies, and I'm struggling to pin down the appropriate data model. The problem that the application aims to solve is: we ...
0 votes
1 answer
418 views
What is the best way in Postgres to inherit values from parent row recursively if not provided?
Is there a pattern in SQL where a child row inherits empty (null?) values from a parent? E.g., given the following 'chickens' table (sorry): id parent_id name flys noise weight egg_color ...
0 votes
1 answer
349 views
Convert numbers to words | Spell out DECIMAL USD 1259.75 as 'One thousand two hundred fifty-nine dollars and seventy-five cents'
ALTER FUNCTION [dbo].[NumberToWords](@Number DECIMAL(18, 2)) RETURNS NVARCHAR(MAX) AS BEGIN DECLARE @Words NVARCHAR(MAX) SELECT @Words = COALESCE(@Words + ' ', '') + CASE WHEN @...
3 votes
2 answers
454 views
How to sum up the distinct Total Time of an Event ignoring duplicate overlaps in Times?
I have the following EventTimes table: DROP TABLE IF EXISTS dbo.EventTimes; CREATE TABLE dbo.EventTimes ( EventTimeKeyId INT IDENTITY(1,1) PRIMARY KEY, EventId INT NOT NULL, StartTime TIME NOT ...