Forum Replies Created

Viewing 15 posts - 616 through 630 (of 4,085 total)

  • RE: Select latest and 2nd latest date rows per user

    kdrymer - Friday, March 8, 2019 4:58 PM

    Hi Drew, this seems to work great! I made a slight tweak to the final...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select latest and 2nd latest date rows per user

    saravanatn - Friday, March 8, 2019 10:45 PM

    kdrymer - Friday, March 8, 2019 4:58 PM

    Hi...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Subset rows with opening and closing balance

    The first thing I would suggest is getting rid of your cteDates.  It is doing absolutely nothing except wasting CPU time.  If you decide that you need one in the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select latest and 2nd latest date rows per user

    Use a CTE/ROW_NUMBER().  Since you didn't provide consumable data, this isn't tested.

    WITH CTE AS
    (
         SELECT
            A.EMPLID
        ,    B.FIRST_NAME
        ,    B.LAST_NAME
       ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL help to match only 3 values

    This will work with most (all?) data types.  I used DENSE_RANK() to filter out duplicates, but ROW_NUMBER() would work in a similar fashion.

    WITH CTE AS
    (

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: The "Numbers" or "Tally" Table: What it is and how it replaces a loop.

    There is a write-up on Dwain Camps' site.  Tally Tables.  If can can, you want to use that to create an inline table-valued function.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: XML Path and table-Valued function?

    You query still doesn't contain a period, and I am not getting an error message when I run your code.  The problem is somewhere else.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: The "Numbers" or "Tally" Table: What it is and how it replaces a loop.

    Jeff Moden - Thursday, March 7, 2019 6:39 AM

    eliassal - Thursday, March 7, 2019 3:19 AM

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL QUERY: Request For Part Overflow

    dderesdd - Wednesday, March 6, 2019 1:21 AM

    WOW...
    Great!!! Thank you!!!

    I need to take into account events that ends at (for example) 10:00...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: XML Path and table-Valued function?

    You generally want to return either XML values or comma-separated values, not both.  It's not clear exactly what you are looking for, but the FOR XML clause can be used...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Parse string based on a list of values

    NineIron - Wednesday, March 6, 2019 10:16 AM

    Thanx for the reply but, that's a bit more involved than 8 replace statements.

    You asked...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Parse string based on a list of values


    WITH Base AS ( SELECT * FROM (VALUES(0), (0), (0), (0), (0), (0), (0), (0), (0), (0) ) t(n) )
    , Tally(n) AS (SELECT ROW_NUMBER() OVER(ORDER BY...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Parse string based on a list of values

    I don't know that it's better, but you could split the string on spaces, filter the results, and then recombine the string.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: SQL QUERY: Request For Part Overflow

    dderesdd - Tuesday, March 5, 2019 7:37 AM

    I have events on my database.
    Every event has datetime to be started and datetime to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select Max record !Help!

    There are two issues here.  The first one is identifying the correct group.  Your English description doesn't match the code.  Your English description says that the records should have the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 616 through 630 (of 4,085 total)