Forum Replies Created

Viewing 15 posts - 61 through 75 (of 125 total)

  • RE: Factor/Rate rounding Issue

    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.

  • RE: Grouping by percentage of time worked by person

    ChrisM@Work (7/2/2014)


    Try this:

    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...

  • RE: Grouping by percentage of time worked by person

    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

  • RE: Dynamically Set Database

    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...

  • RE: Dynamically Set Database

    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...

  • RE: Dynamically Set Database

    What is the query you're trying to run?

    Would you be able to provide any DDL and sample data?

  • RE: Dynamically Set Database

    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...

  • RE: First and Last day of the month in a given date range

    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...

  • RE: Assigning Batchid to Cake Making Process

    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,...

  • RE: Assigning Batchid to Cake Making Process

    sunil.mvs (4/11/2014)


    Cake can have x steps and it depends on customer request .. Once work flow starts it starts with 1 and reaches nth...

  • RE: Assigning Batchid to Cake Making Process

    sunil.mvs (4/11/2014)


    Hi Doshan ,

    Query is working as expected ... Number of intermediate Steps in delivery of cake will vary . So ...

  • RE: Assigning Batchid to Cake Making Process

    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...

  • RE: How can I track how many times a specific SP is called every day?

    MyDoggieJessie (4/3/2014)


    I used to do it using a sp as well, then discovered it was a heck of a lot easier with the trace, then created a process to import...

  • RE: Pivot Table

    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...

  • RE: Pivot Table

    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

Viewing 15 posts - 61 through 75 (of 125 total)