Forum Replies Created

Viewing 15 posts - 661 through 675 (of 1,923 total)

  • RE: Ordering with nulls

    zapouk (8/31/2011)


    That seems to do it. I'd experimented with case and isnull but never got as far as using them using together. Thanks for this!

    You're welcome. Thanks for setting up...

  • RE: Ordering with nulls

    toddasd (8/31/2011)


    ColdCoffee (8/31/2011)


    This will be more robust:

    select ColA, ColB

    from TestTable

    order by isnull( ColA , ColB) ,

    case when ColA is...

  • RE: Ordering with nulls

    toddasd (8/31/2011)


    Nice shot, CC. You got there seconds before me 😉

    😀

  • RE: Ordering with nulls

    This will be more robust:

    select ColA, ColB

    from TestTable

    order by isnull( ColA , ColB) ,

    case when ColA is not null...

  • RE: Ordering with nulls

    How about this ?

    select ColA, ColB

    from TestTable

    order by isnull( ColA , ColB) , isnull( ColB ,ColA )

  • RE: Get list of months, monthname and Year

    A more cleaner version:

    DECLARE @StartDATE DATETIME

    SET @StartDATE = '01-01-1985'

    ;WITH Tens (N) AS

    (

    SELECT 0 N UNION ALL SELECT 0 UNION ALL SELECT 0 UNION ALL

    ...

  • RE: Get list of months, monthname and Year

    If you dont have a tally table, you can utilize this code :

    DECLARE @StartDATE DATETIME

    SET @StartDATE = '01-01-1985'

    ;WITH Tens (N) AS

    (

    SELECT 0 N UNION ALL SELECT...

  • RE: Trying to Pull the First Incomplete Operation

    And Mr ( or Ms ) sdownen05 , thanks for setting up the problem fantastically 🙂 Right on the money ; appreciated 😎

  • RE: Trying to Pull the First Incomplete Operation

    Or this:

    ; WITH Distinct_Jobs AS

    (

    SELECT DISTINCT Job

    FROM #JobOrder

    )

    SELECT CrsAppOutput.Job , CrsAppOutput.OperName , CrsAppOutput.Operation , CrsAppOutput.Complete

    FROM Distinct_Jobs OuterTable

    CROSS APPLY

    (

    ...

  • RE: SUM relative to row date value

    And with proper index on YearMonth column, the script should complete in a jiffy. I wonder if a Quirky Update code can be bestowed on this puzzle :unsure:

  • RE: SUM relative to row date value

    Cadavre (8/31/2011)


    Nice one Chris 😉

    Told you someone would simplify it Greg

    Wooooosh... i dint see Chris posted a similar solution 😉

    { Note to self : Brush the teeth before even...

  • RE: SUM relative to row date value

    Wont this do?

    Shamelessly utilizing the sample data that Cadavre prepared( Thanks Cad)

    DECLARE @TABLE AS TABLE (Yearmonth DATETIME, Metric1 INT, Metric2 INT)

    INSERT INTO @TABLE (Yearmonth, Metric1)

    SELECT '2010/01/01', 1 UNION ALL

    SELECT...

  • RE: PIVOT result column format

    patrick.bewley (8/30/2011)


    This query has been simplified from a dynamically built PIVOT query.

    I so expected this 🙂 I need to just hash thro some of my old code,...

  • RE: PIVOT result column format

    I second what Sean says, formatting is to done at the front end.

    But, doesnt this work for you ( or am i missing the obvious ?? )

    DECLARE @Budget TABLE

    (

    ID INT...

  • RE: How can I Make it 10 All the time?

    simflex-897410 (8/29/2011)


    WOW, great stuff!

    Thanks a lot for the prompt response and your help. Works great!!

    Glad i could help 🙂

    Have a look at my previous post also on not casting an...

Viewing 15 posts - 661 through 675 (of 1,923 total)