Forum Replies Created

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

  • RE: Holding invoices

    I believe that this does the same thing, but without the CTE. It was impossible to do a performance comparison on such small data.

    SELECT i.rowid, i.CustomerID, i.InvoiceNumber, i.InvoiceTotal, i.InvoiceAge,...

  • 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

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

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

  • RE: looping help

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

    Drew

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

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

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

  • 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

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

  • 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]

    ...

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

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

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

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

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