Forum Replies Created

Viewing 15 posts - 91 through 105 (of 4,080 total)

  • Reply To: Any SQL developer volunteers needed?

    Listen to Jeff on this.    He helped me out tremendously, as he has helped countless others.

     

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Reply To: STIntersect

    You first need to do some research on spatial concepts.    You can only consider flight paths to be straight lines over very small distances.    If you are flying...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Reply To: Extract rows from a table/CTE when a column matches

    Could we by any chance look at the underlying CTE that you mentioned?

     

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Reply To: Extract rows from a table/CTE when a column matches

    Your solution will get the correct result, but it is running the entire First4Count_Cte twice.    Basically generating a huge number of rows and then filtering them out.    The...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Reply To: T-SQL PIVOT or something else??

    The PIVOT function will do what you want.    You can also google for the old school way of doing a pivot.   It's called a "Crosstab".

    I find the syntax easier...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Reply To: Convert European format values to US Format

    This isn't pretty, but it seems to work.

    The code assumes that '^' is a safe character to use to bookmark the position of the ending period.   If not, pick another. ...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Reply To: CASE WHEN EXISTS UPDATE

    It helps to remember that, in SQL, CASE is an expression, not a flow control statement.   All CASE does is use if/then/else logic to produce a single value.

    Your original logic...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Reply To: Are the posted questions getting worse?

    And this thread just keeps on keeping on...

    This is a pure rant, so read at your own risk.

    I have been involved in the interview process for a senior sql developer...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Week Number with custom dates


    declare @start date = '2018/08/01'

    ;with tally (N) as (select top 366 row_number() over(order by (select null)) from sys.columns c1 cross join sys.columns c2)
    select Dateadd(day,N-1,@start)...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Declare start date as yesterday and end date as today

    Are you simply wanting to not include weekend days (Saturday, Sunday), or are you trying to find the previous BUSINESS day?

    If you are looking for the previous business...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: get the data from last modified

    If you aren't afraid of CTEs, use this syntax.   😉


    ;with cte1 as (select id, pro, [type]
                        , coalesce(qty1,lead(qty1,1) over(partition by pro, [type] order by modifieddate...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: get the data from last modified

    Another variation.   For a huge file, I hope there is a covering index on the Pro, Type, and Modified Date columns.


    select id, Pro, [Type], Qty1,Qty2,...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Creating a non-unique index

    Jeff is indeed the MASTER OF THE TALLY TABLE.... and many other things besides.  😉

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Parse string based on a list of values

    Not recursive at all, just a cte.    But yes, it finds the first space from the right to pull the strings to be tested.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Parse string based on a list of values

    One more variation:


    select #t.*
            , case when right(Disposition,nullif(charindex(space(1),reverse(disposition)),0)-1)
                        in ('CH', 'HC', 'MA', 'NH', 'OA', 'OTH', 'PSY', 'SNF')
                     then right(Disposition,nullif(charindex(space(1),reverse(disposition)),0)-1) end as ShortCode
    into #r2

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

Viewing 15 posts - 91 through 105 (of 4,080 total)