Forum Replies Created

Viewing 15 posts - 766 through 780 (of 1,413 total)

  • Reply To: Is there anything equivalent to a Last() Function

    Yes the LAST_VALUE function is a windowing function.  One way to summarize would be to use a common table expression.

    with lv_cte(PrimaryKey, SearchValue, OtherNumericValue, LastValue) as (
    ...

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

  • Reply To: Is there anything equivalent to a Last() Function

    There's the LAST_VALUE function.  In order to return the "last value" (when the set is ordered by:  OVER (ORDER BY ...)) across the entire window of rows (in this case...

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

  • Reply To: query filter

    Style-wise, the joins are specified in "more specific to less specific" order which imo is not the standard way and it's less read-able.  Without knowing anything about the underlying data...

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

  • Reply To: query filter

    The query references "a couple of joined tables" but the code listed only has 1 table 't' in the FROM clause.  The error message "multi-part identifer ..." happens when the...

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

  • Reply To: Query is hanging

    The nested subqueries seem not to be necessary imo.  What is the point of selecting the top 15 rows only to select the top 1 from that subset using the...

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

  • Reply To: is value is contained in column - new column

    It appears the OP is referencing Excel functions and column arrays.  In this query the calculated NewColumn equals the DesiredColumn.

    drop table if exists #tTable;
    go
    create table #tTable(
    ...

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

  • Reply To: How often have you needed to start a sequence of numbers at other than 1 or 0?

    Jeff Moden wrote:

    Awesome stats.  Thank you good sir.  And, based on your previous replies, the other 13 or so all start at "0"?

    Yes, the other 13 start with 0, meaning 'dbo.fnTally(0,...

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

  • Reply To: How often have you needed to start a sequence of numbers at other than 1 or 0?

    I use 2 monster .sql scripts to answer SSC/SO questions.  One currently has 13,787 lines and contains 32 occurrences of 'fnTally' of which 24 specify the sequence begin with 1. ...

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

  • Reply To: How often have you needed to start a sequence of numbers at other than 1 or 0?

    Jeff Moden wrote:

    Thanks for the feedback, Steve.  So, from the sounds of it, you don't use a starting value of other than "0" or "1", correct?

    Those are my two choices so...

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

  • Reply To: How often have you needed to start a sequence of numbers at other than 1 or 0?

    Jeff Moden wrote:

    Getting back to Itzik's challenge, I had a question form in my mind.  As a pre-amble to the question, I've found that I use "1" as a starting number...

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

  • Reply To: Query Code returning incorrect results

    I think maybe it should be 'where c.id=o.cust_id'  🙂

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

  • Reply To: Query Code returning incorrect results

    The table #tmpTabl specifies the column 'id' twice.  Presumably the second 'id' is the unique identifier of the 'orders' table so here it's renamed as 'o_id'.

    drop table...

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

  • Reply To: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Sergiy wrote:

    How about "This string is a space separated string"?

    will this function work?

    By "work" if you mean "give the right answer" then no.  It doesn't return any error though.  But...

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

  • Reply To: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Yes the logic is broke.  I agree with all of Alan's comments.  It seems possible to take corrective steps using cte(s) and additional windowing functions where the cardinality of the...

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

  • Reply To: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Jeff Moden wrote:

    corey lawson wrote:

    Hey, Jeff, will you update this yet again to include the new split_string() function in SQL Server 2016+?

    Probably not. The STRING_SPLIT function is relatively crippled for those that...

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

Viewing 15 posts - 766 through 780 (of 1,413 total)