Hey guys i have this query:
What it does is creates a temp table with the number of hours between given days... then it goes and finds a % on a table and puts it next to the hour/day.
So your end result is two columns,
CYCLEDATE POINT
Cycle day is the day and individual hour and POINT is the percentage.
Sometimes the percentages are duplicate... So how could I loop through this table after it is create and remove the duplicate rows (based on "POINT") then present that data?
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
Code:
DECLARE @COUNT DECIMAL (6,1)
DECLARE @START_DATE DATETIME
DECLARE @END_DATE DATETIME
DECLARE @DURATION_HH DECIMAL (6,1)
DECLARE @DURATION_PCT DECIMAL (6,3)
CREATE TABLE #PROJECTED_CURVE --Prepare Temp Table
(
CYCLEDATE Datetime,
[COUNT] INT,
DURATION_HH INT,
DURATION_PCT Decimal(6,3),
PROJPOINT Decimal(6,3)
)
SET @COUNT = 0
--Retrieve and set Start Date
SELECT @START_DATE = RCYC_START_DATE
FROM RELEASE_CYCLES WITH (NOLOCK)
WHERE RCYC_ID = @Cycle
--Retrieve and set End Date
SELECT @END_DATE = RCYC_END_DATE
FROM RELEASE_CYCLES WITH (NOLOCK)
WHERE RCYC_ID = @Cycle
--Calculate project Duration in hours based on start date and end date
SET @DURATION_HH = DATEDIFF(DD, @START_DATE, @END_DATE) + 1
--Build a row for each hour in Cycle
WHILE (@COUNT) < @DURATION_HH + 1
BEGIN
--Calculate the Duration PCT for the hour of the Cycle
SET @DURATION_PCT = ROUND(((@COUNT / @DURATION_HH) * 100) ,0)
--Insert the values into the temp table
INSERT INTO #PROJECTED_CURVE (CYCLEDATE, [COUNT], DURATION_HH, DURATION_PCT, PROJPOINT)
VALUES (DATEADD(DD,@COUNT,@START_DATE), @COUNT, @DURATION_HH, @DURATION_PCT, 0.000)
Set @COUNT = @COUNT + 1
CONTINUE
END
SELECT CYCLEDATE, POINT FROM #PROJECTED_CURVE, SQA_DASH_PROJECTED_CURVE WITH (NOLOCK)
WHERE #PROJECTED_CURVE.DURATION_PCT = SQA_DASH_PROJECTED_CURVE.[ORDER]
DROP TABLE #PROJECTED_CURVE
What it does is creates a temp table with the number of hours between given days... then it goes and finds a % on a table and puts it next to the hour/day.
So your end result is two columns,
CYCLEDATE POINT
Cycle day is the day and individual hour and POINT is the percentage.
Sometimes the percentages are duplicate... So how could I loop through this table after it is create and remove the duplicate rows (based on "POINT") then present that data?
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008