All Questions
17 questions
0
votes
0
answers
248
views
Recursive Query to calculate Folder Size
I have the following scenario which I am trying to execute in my SQL Server:
Root Folder (dataID - 001)
Folder A (dataid-123)
child folder 1
...
1
vote
1
answer
390
views
Grouping shift data by 7-day windows in SQL Server 2012
What I want to do is to calculate the number of shifts and hours worked by each employee in any given 7-day period. In order to achieve this, I need to identify and group 'islands' of shifts. Note ...
0
votes
1
answer
106
views
How to sum the values of a column in SQL Server from the current row to the last within a CTE
SQL FIDDLE
I tried to sum the column qx in my CTE from the current row to the last row creating a calculated column called qxsum like the following:
declare @idade int = 25
declare @sexo char = 'm'
...
0
votes
2
answers
1k
views
Performance tuning on Recursive CTE
I have the following table with sample data:
Table: tbl_nodes
create table tbl_nodes
(
nod1 varchar(50),
nod2 varchar(50)
);
Sample data:
insert into tbl_nodes values('Node1','Node2');
...
2
votes
1
answer
661
views
How to get time from 00 to 23 using recursive CTE?
How do I get hours of a day from 00 hrs to 23 hrs using recursive CTE?
It gives hours 00 to 24, but I need to exclude the 24 hrs in my result set or in other words I need only up to 00 to 23 hrs
My ...
3
votes
1
answer
180
views
Arithmetic calculation using previous record for two columns which depends each other in sql
In my table I have to calculate values for different columns. The values can be arrived from current row and previous row. These two column values depends on each other.If I change values of one ...
2
votes
4
answers
1k
views
Recursive SQL query to find all matching identifiers
I have a table with following structure
CREATE TABLE Source
(
[ID1] INT,
[ID2] INT
);
INSERT INTO Source ([ID1], [ID2])
VALUES (1, 2), (2, 3), (4, 5),
(2, 5), (6, 7)
Example of ...
0
votes
1
answer
191
views
Recursive SQL Query with Defined Start Point
I'm trying to get a recursive query to work with a defined starting point.
Here's some sample data from my table called Part_v_Container:
Serial_No From_Container Part_Key Part_Operation_Key
...
0
votes
1
answer
275
views
T-Sql Calculate averages using Recursive CTE
I have the below table and have constructed a recursive CTE query which calculates the average price of the stock for a particular [item no] and the first receipt and uses that average to calculate ...
1
vote
2
answers
751
views
Counting consecutive shift and days in SQL
I am trying to display the number of consecutive Shifts and Days a team has worked. I have tried a number of solutions but just cannot get it quite right.
The data is Date, Shift, Crew. There is a ...
1
vote
3
answers
320
views
show only categories that have products in them
excuse the bad title but I couldn't find a good way to express what I want in abstract terms.
Anyway I have 3 tables
tbl_product:
PID | productname
1 | product 1
2 | product 2
3 | product 3
...
0
votes
1
answer
48
views
How to approach to find parents for child in sql server 2012?
I've a table like this:
If I'm given a single or a list of menuID, I need to find the all the parents for all the menuID. For Example if I'm given MenuID as 1601120013, I need to find the following.
I'...
2
votes
2
answers
175
views
How to output using recursive (parents -> children -> grandchildren)
CREATE TABLE PERSON
(
persID INT IDENTITY(1,1) PRIMARY KEY,
persFName VARCHAR(30) NOT NULL,
persLName VARCHAR(30) NOT NULL,
persDOB DATE,
motherID INT FOREIGN ...
1
vote
1
answer
39
views
Having difficulty understanding many-to-many recursive
CREATE TABLE PERSON
(
persID INT IDENTITY(1,1) PRIMARY KEY,
persFName VARCHAR(30) NOT NULL,
persLName VARCHAR(30) NOT NULL,
persDOB DATE,
motherID INT FOREIGN ...
2
votes
2
answers
297
views
Recursively Distribute Rows in Sql server
I have problem to device a query which will be used to obtain information from existing rows for other rows.
Existing table data
In above image there are three rows for RecptNo 20100001182.
In ...