Forum Replies Created

Viewing 15 posts - 2,761 through 2,775 (of 4,085 total)

  • RE: Using JOINs with GROUP BYs

    T-SQL was designed to mirror English, so the order of processing does not match the written order. Queries are processed in the following order:

    FROM

    WHERE

    GROUP BY

    HAVING

    SELECT

    ORDER BY

    TOP/OFFSET-FETCH

    Each step produces a...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Remove/Keep record based on group

    Lynn Pettis (3/28/2016)


    scottcabral (3/28/2016)


    works, thanks!

    It works as long as there aren't two rows of data for the same Download, AccountNum, RootPolicyNum where CurrentStatus = 'Renewed' for both.

    I think that can...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Difference between Full Outer and Cross Join

    Hugo Kornelis (3/28/2016)


    (**) The "next" here refers to the logical processing order; the actual processing order chosen by the Query Optimizer can be different as long as the results are...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: To include above details in whre clause

    You can always use a CASE expression, but it sounds like you might have a LOT of cases, so a table value constructor might be a better approach. You...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: indexes-non clustered

    Hugo Kornelis (3/23/2016)


    criterium

    Completely off-topic, but criteria is from Greek, so it uses the Greek singular criterion rather than the Latinate singular criterium

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Looping and scalar value

    I agree that there are cases where the order is important, but my point was that the number of cases is far smaller than most people think. Running aggregates...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Looping and scalar value

    Eirikur Eiriksson (3/21/2016)


    kuopaz (3/21/2016)


    I see, thanks. As it's scanning the tally table row-by-row from start to the predicate value, the order of N may be important in some cases (not...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Add two columns to make one total

    lkennedy76 (3/17/2016)


    Jeff Moden (3/16/2016)


    lkennedy76 (3/16/2016)


    After a long hard battle of 'I don't wanna', the temp table is the best option in this scenario.

    Thank everyone for all your replies. I am...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Optimize SP

    You're using temp tables to store results that are only used once(#MinPeriod and #MaxPeriod). It is better to use a CTE or a derived table for single use temporary...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Optimize SP

    When posting optimization questions, it really helps to provide the actual execution plan (or at least the estimated execution plan).

    That being said, the first thing I see is an overuse...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Getting values which dont join

    Actually, the best approach is to CROSS JOIN your missing Jobs table with your status table and then LEFT JOIN to the job status table. That way you don't...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Conditional column display

    This type of formatting is usually best left to the presentation layer, SSRS for example.

    The only way to do it in T-SQL is with dynamic SQL.

    If you tell us what...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Understanding the OVER clause

    The range is actually much more flexible than stated. For example these are all valid ranges:

    BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING

    BETWEEN 10 PRECEDING AND 5 PRECEDING

    BETWEEN 1 FOLLOWING AND...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Add two columns to make one total

    lkennedy76 (3/15/2016)


    I took out the ISNULL, the SUM function requires a group by so I grouped it by ID not the amounts, all amounts are now NULL

    As Gail already said,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Sql Results to appear on 1 Row

    This type of request is usually best done in the presentation layer, such as SSRS or even an Excel Pivot Table.

    If you insist on doing it in SQL you'll need...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,761 through 2,775 (of 4,085 total)