Forum Replies Created

Viewing 15 posts - 736 through 750 (of 1,424 total)

  • Reply To: pivot on 2 fields

    Based on the data that's been provided the two tmp_day values are '01' and '02' which don't seem to vary by month.  As to which column is subordinate to the...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: pivot on 2 fields

    An alternative to PIVOT is conditional aggregation.  The sample data provided only contains 1 value for 'tmp_day' which seems to not agree with the output.  So I changed the sample...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Common Table Expression Misunderstandings

    In the first paragraph it says "Windowing functions are limited to the SELECT and OVER clause..."  Correction, windowing functions are permitted in both the SELECT list as well as the...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Array into table.

    If the array is really JSON then Mark Cowne's answer seems correct.  If it's just a delimited string with repeating fixed length segments then something like this could work

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Please help to get duration between two 4 or 3 character string

    A middle way could be to use the very nice integer division Jeff uses for the time parts but then use framework functions to handle type conversions and calculation.  Supposedly,...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Need to create gaps in a table of date ranges

    One "brute force" way to do this would be to expand all the date ranges and use the set operator EXCEPT to remove the (also expanded) gaps.  Then the results...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Can anyone explain the design decision here?

    To generate a sequence why not use an explicit virtual table of the numbers themselves?   Here's a .txt file with a sql script and it defines a tvf called dbo.fn1k...

    Attachments:
    You must be logged in to view attached files.

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Can anyone explain the design decision here?

    Yes plenty of time.  Lots of time.  Eons and eons.  More than Ten Centuries 🙂  Enough to fill BIGINT.  It could be dialed back as appropriate.

    • This reply was modified 5 years, 9 months ago by Steve Collins.

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Can anyone explain the design decision here?

    The place to start imo is with this very awesome article from Jeff.  I agree the code is not efficient.  The key is to have a 'row goal' in...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Returning single row multiple values

    There were a few issues with the data which required fixing before a query could run.  The VARCHAR columns require a character length, in this case I made them both...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Update Column Based on Criteria from Other Columns -- improved post included DDL

    Hi Lonnie, thanks for the follow up.  Since inside the WHILE loop the variable @i represents the theoretical cycle, perhaps it makes sense to change the WHERE clause to

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Cursor and Subtraction Assignment Logic Issue

    To the OP it makes clear sense no doubt.  In this case the OP says they have part of the solution but only offer pictures of the problem.  Maybe we...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Data between 2 dates (different years)

    It seems dfp(start_dt) should've been dfp(dt) in two places.   This is a really slow way to debug 🙂

    with
    dt_cte(dt) as (
    select dateadd(month, fn.n, dfp.start_dt)
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Data between 2 dates (different years)

    dfp(start_dt) is (or was intended to be) the alias (with column label) for the object defined by the VALUES table value constructor.  It appears there some were missing parentheses in...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Sequencing query

    By "regroup"  does it mean "round and expand"?  Otherwise, how to handle the decimal precision?  To create 1 foot increments based on rounded ranges you could use a tally...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Viewing 15 posts - 736 through 750 (of 1,424 total)