Forum Replies Created

Viewing 15 posts - 4,111 through 4,125 (of 8,761 total)

  • RE: Record count in results

    Another quick solution, similar to John's apart from this one is counting in both directions

    😎

    USE tempdb;

    GO

    SET NOCOUNT ON;

    /* SAMPLE DATA SET */

    ;WITH SAMPLE_DATA(RN,NAME) AS

    (

    SELECT 1,'Mary'...

  • RE: Averages over 28 days instead of a month

    Raastarr (1/4/2016)


    Thanks for all of the responses.

    I've gone with the first solution from Eirikur as it did exactly what was required :-).

    You are very welcome and thanks for the feedback.

    😎

  • RE: Why Scalar Functions Can Be Costly

    Thank you Mickey for this article, good Monday morning reading.

    The part I find hard to agree with is "When to Use Scalar Functions", particularly when the example given can easily...

  • RE: Averages over 28 days instead of a month

    Jeff Moden (1/3/2016)


    Now would be a good time to shift the train of thought to ISO Weeks, which always start the year in the week that Jan 4th occurs. ...

  • RE: Averages over 28 days instead of a month

    Good job with the DDL and the sample data Raastarr, made this very quick and straight forward question to answer;-)

    😎

    There are few ways of doing this, here is the first...

  • RE: query for datetime

    Timing the different methods using the previously posted test data set

    😎

    Test harness

    -- TEST: Different ways of calculating duration

    -- DATA SET: ...

  • RE: Using User Defined functions with SQL Window operations

    This is not possible in this way, the over clause cannot be used with user defined functions.

    😎

  • RE: query for datetime

    Jeff Moden (1/1/2016)


    Eirikur Eiriksson (12/31/2015)


    Careful here Jeff, the type cast to decimal is expensive, consider using float which does not need a type cast is less costly.

    Understood. FLOAT only...

  • RE: Multiple parameter function !

    Orlando Colamatteo (1/1/2016)


    Eirikur Eiriksson (12/21/2015)


    GilaMonster (12/21/2015)


    I don't think that functions have optional parameters that can be left out of the call

    That's correct, neither optional parameters nor default values can be...

  • RE: The Most Common Query Blunders...

    Jeff Moden (1/1/2016)


    Heh... without going into too many details, I've found that one of the most common query blunders is the nearly religious belief in rote, so called "best practices"...

  • RE: query for datetime

    drew.allen (12/31/2015)


    Jeff Moden (12/30/2015)


    Here's the code I wrote last night with the validation checks that I added today. Details are in the comments in the code.

    GREAT! But suppose your...

  • RE: query for datetime

    Ed Wagner (12/31/2015)


    Eirikur, I've really come to enjoy your test harness. I particularly like how it uses the actual execution times instead of SET STATISTICS and I appreciate the...

  • RE: Are the posted questions getting worse?

    Happy new year and may the source be with you.

    😎

  • RE: query for datetime

    Jeff Moden (12/30/2015)


    --=================================================================================================

    -- Calculate the sum of the durations

    --=================================================================================================

    --===== Calculate the total duration in decimal hours.

    -- This won't break if...

  • RE: It's the end of the year

    Happy new year!

    😎

Viewing 15 posts - 4,111 through 4,125 (of 8,761 total)