Forum Replies Created

Viewing 15 posts - 721 through 735 (of 1,413 total)

  • Reply To: Are the posted questions getting worse?

    Spam is one thing but don't let anyone convince you to try scrapple.  It's not "the same thing" it's not even "similar" 🙂

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

  • Reply To: pivot multiple columns and transpose to same row sql server

    It seems you're looking to include the ROW1 column in the GROUP BY and ORDER BY clauses but not in the SELECT list.  Otherwise, it seems to be a standard...

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

  • Reply To: Appttime add with duration how to get endtime please

    The math could look something like this

    declare @data table (app_time varchar(8), 
    ...

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

  • Reply To: How to write update query to check exist column by value 1 where it exist on tab

    Here's a simple way which avoids counting

    with
    a_cte as (select distinct PartId from #FeaturesvalueA),
    b_cte as (select distinct PartId from #FeaturesvalueB),
    x_cte as ((select * from a_cte except select *...

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

  • 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, 4 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

  • Viewing 15 posts - 721 through 735 (of 1,413 total)