All Questions
12 questions
-1
votes
1
answer
78
views
Extraction of Parents by hierarchy for employees using Azure Synapse Analytics
I am looking for a solution for the below situation:
I have to extract all the managers (by hierarchy) for some employees that i receive in the flow (we have a file that contains all the information ...
-1
votes
2
answers
281
views
Get the Whole List from a many to many relation [duplicate]
i have the following schema
CREATE TABLE BookRelationship
(Id int IDENTITY(1,1) PRIMARY KEY, Book1 nvarchar(50), Book2 nvarchar(50))
INSERT INTO BookRelationship (Book1,Book2) VALUES
('Book 42','...
0
votes
2
answers
491
views
T-SQL: Self-Referencing calculated field
I'm trying to calculate the daily total number of Day Trades based on an existing table that provides the cumulative number of Day Trades over a rolling five-day window (business days only). The data ...
2
votes
1
answer
403
views
Use CTE Instead of Table Variable for Recursive Function
I am trying to create a loop that when given a part id, it will search a table of assembly parts and put all the parts into the return table. I.e. I want to explode the parts from a single part id.
It ...
0
votes
2
answers
336
views
Recursive CTE to populate latest available data across many quarters?
here is a sample dataset:
CREATE TABLE UholdingsPE(
Reference_Date DATE NOT NULL PRIMARY KEY
,Investment VARCHAR(14) NOT NULL
,Holding VARCHAR(9) NOT NULL
,Price INTEGER ...
0
votes
3
answers
302
views
Lazy upward recursive query in sql
I'm trying to generate a path from the name of an item's parents. For example if test has for parent dad the path would be dad/test; and if dad had for parent gran the path of test would be gran/dad/...
-1
votes
1
answer
65
views
How can I select the top level of a hierarchical relationship in SQL?
I have a list of routines that need to be ran, and a table which defines whether a routine is dependent on the successful completion of other routines or not. So for example:
| RoutineID | ...
2
votes
2
answers
268
views
Recursive CTE (T-SQL) Returns Un-expected Result
I've been staring at this code for WAY too long, trying to figure out why my final query returns unexpected results.
Any help would be much appreciated. Thanks in advance.
Given the following code (...
0
votes
1
answer
655
views
TSQL recursive query help parent-child
I'm trying to build a t-sql query that will return parent and its child accounts in the same table based on a roll-up input. Can someone please assist?
***TABLE:USERS***
UserId ParentId
66 ...
3
votes
1
answer
4k
views
How to speed up a recursive CTE
Given the following recursive CTE (simplified a bit for my example):
WITH myCTE (sort, parentid, myid, level, somedata)
AS
(
-- Anchor member definition
SELECT
CAST(ROW_NUMBER() OVER(...
3
votes
2
answers
3k
views
Genealogy Tree in SQL Server
In my table each record has a pointer to his direct parent and I need to know how to query for all the descendants, direct or not (the son of a son), of a given record.
Facts:
I don't know how ...
0
votes
3
answers
240
views
Aggregate survey results recursively by manager
I have a StaffLookup table which looks like this.
UserSrn | UserName | ManagerSrn
===============================
ABC1 | Jerome | NULL
ABC2 | Joe | ABC1
ABC3 | Paul | ABC2
ABC4 ...