Viewing 15 posts - 61 through 75 (of 125 total)
Fantastic stuff Eugene.
I'd be playing around with something along these lines, but hadn't quite got to this yet.
Thanks for the help.
September 9, 2014 at 5:31 am
ChrisM@Work (7/2/2014)
SELECT PersonID, StartMonth = MIN(MONTHID), EndMonth = MAX(MONTHID), LOADPCT = PercentLoad
FROM (
SELECT *,
[Grouper] = MONTHID - ROW_NUMBER() OVER(PARTITION BY PersonID, PercentLoad ORDER BY MONTHID)
FROM...
July 2, 2014 at 7:14 am
This work?
SELECTT.PersonID,
StartMonth= MIN(MonthID),
EndMonth= MAX(MonthID),
T.PercentLoad
FROM
(
SELECTRN = T.MonthID - ROW_NUMBER() OVER (PARTITION BY T.PersonID,T.PercentLoad ORDER BY T.PercentLoad),
T.PersonID,
T.PercentLoad,
T.MonthID
FROM#TestProject2 AS T
WHERET.PercentLoad > 0
) AS T
GROUPBYT.PersonID,
T.PercentLoad,
T.RN
ORDERBYT.PersonID ASC,
StartMonth ASC
July 2, 2014 at 7:13 am
I've tried to recreate this and without knowing the DDL of the tables etc. I've had to take a bit of a punt, but seems to work for me?
Are you...
June 26, 2014 at 5:21 am
Without having anything to run it against it's hard to diagnose.
does your string look something like:
SELECT @Command = N'
USE [' + @DatabaseName + '];
SELECTs.[Name],
COUNT(DISTINCT s.[SessionId]) AS [SessionCount],
SUM(DATALENGTH(rd.[TermData])) AS [TotalSessionSize]
FROM[Session] AS...
June 26, 2014 at 4:51 am
What is the query you're trying to run?
Would you be able to provide any DDL and sample data?
June 26, 2014 at 4:35 am
Does something like this work for you (You may wish to adjust the part to get database names to suit your needs)?
DECLARE@CounterINT = 1,
@CommandNVARCHAR (255),
@DatabaseNameNVARCHAR(255)
DECLARE @test-2 TABLE
(
IDINT IDENTITY(1,1)NOT...
June 26, 2014 at 3:50 am
As a caveat this is pre-first morning tea, but should work.
DECLARE @StartDate DATETIME = '2016-06-21 16:57:11.093',
@EndDate DATETIME = '2016-09-30 00:00:00.000';
SELECTMonthStartDate = DATEADD(MONTH, DATEDIFF(MONTH, 0, @StartDate) + N,0),
MonthEndDate = DATEADD(MONTH,DATEDIFF(MONTH,0,@StartDate)+ N...
June 26, 2014 at 2:11 am
sunil.mvs (4/12/2014)
Solution is fine . The other scenario will not arise which i clarified from business ..
If the number of steps can differ by cake ID,...
April 12, 2014 at 8:37 am
sunil.mvs (4/11/2014)
April 11, 2014 at 8:28 am
sunil.mvs (4/11/2014)
Query is working as expected ... Number of intermediate Steps in delivery of cake will vary . So ...
April 11, 2014 at 6:31 am
It's a bit early and I haven't had a tea yet, but I think this does the job (Haven't tested this extensively).
IF OBJECT_ID(N'tempdb..#Bakery',N'U') IS NOT NULL
DROP TABLE #Bakery;
CREATE TABLE #Bakery
(
CakeIDINTNOT...
April 11, 2014 at 1:46 am
MyDoggieJessie (4/3/2014)
April 4, 2014 at 1:46 am
I'll also recommend this as a cross-tab which helps with the readability.
SELECTT.Gruppo_Assegnatario,
SUM(CASE WHEN Stato = 'Sospeso' THEN 1 ELSE 0 END) AS Stato1,
SUM(CASE WHEN Stato = 'Assegnato' THEN 1 ELSE...
March 25, 2014 at 7:29 am
What Luis means is you're pivoting on data that doesn't exist on your test data, which is why the count is coming out as 0.
Take a look at this:
DECLARE
March 25, 2014 at 7:25 am
Viewing 15 posts - 61 through 75 (of 125 total)