Forum Replies Created

Viewing 15 posts - 2,401 through 2,415 (of 4,085 total)

  • RE: SQL Code QA

    Also, my approach can easily be used with derived tables, again being consistent. You're approach could quickly become cumbersome with derived tables.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL Code QA

    david.wright-948385 (9/8/2016)


    Phil Parkin (9/8/2016)


    I disagree. It makes perfect sense. He *always puts ON clauses on separate indented lines* – perfectly consistent.

    That's the point I'm making - it's consistent, but no...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL view performance problem

    The Dixie Flatline (9/8/2016)


    There is a potential problem right up at the front. The codes starts with a "Date_Dataset" cte that does a SELECT DISTINCT to produce a...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: looping help

    What are your expected results? It's certainly not clear from your description.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL query permutations using 3 tables without repetition

    Are you by any chance looking for this?

    SELECT TOP(5) * FROM TopSellerInstrumentsLastWeek i

    FULL OUTER JOIN TopSellerScoringLastWeek sc

    ON i.pf_id = sc.pf_id

    FULL OUTER JOIN TopSellerStyleLastWeek st

    ON i.pf_id = st.pf_id

    OR sc.pf_id = st.pf_id

    ORDER...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL Code QA

    Luis Cazares (9/7/2016)


    colin.dunn (9/7/2016)


    Put the join ON clauses on the same line since they were so short.

    I usually have my ON clauses on the same line as my JOIN, but...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL query permutations using 3 tables without repetition

    20,000+ rows does not constitute SAMPLE data. If you need more than 100 rows to illustrate your problem, then it's too complex for a free forum. Why...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Weird - When creating a table, it changes the schema to domain/user... but only for one group?

    You need to set the user's default schema.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to use One to many relation with sub-query

    There are several issues here.

    1) Your data is not in a format that people can cut and paste it into SSMS to get started. Follow the instructions in...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Year to date with Year and Week

    The Dixie Flatline (9/5/2016)


    Just a guess here but have you tried adding this to your OVER clause?

    SUM([CY_Quantity]) OVER (PARTITION BY [Customer], [Product], [Year]

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Case Statement Help

    If you're not sure, instead of using an "OR", add another CASE. This will both make it easier to understand your logic and prevent problems with not specifying the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Is it a bad idea to declare a cursor within a TRY block?

    Lynn Pettis (9/1/2016)


    ScottPletcher (9/1/2016)


    Luis Cazares (9/1/2016)


    drew.allen (9/1/2016)


    First, the mantra is "It's a bad idea to declare a cursor. Period. End of sentence." 😀

    Drew

    Second, cursors can be local or global and...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Is it a bad idea to declare a cursor within a TRY block?

    First, the mantra is "It's a bad idea to declare a cursor. Period. End of sentence." 😀

    T-SQL is not C#. It's certainly easy enough to test.

    DECLARE @i INT =...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to fine tune cursor by rewrote the code

    One thing I noticed is that you spread out Aj_total into different balances based on Age, and then the next thing you do is a series of queries to collapse...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Update column based on filter

    Your database is not normalized properly. If you can, you'd be better off fixing that rather than trying to code around it.

    It always helps to provide sample data in...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,401 through 2,415 (of 4,085 total)