Forum Replies Created

Viewing 15 posts - 541 through 555 (of 4,085 total)

  • Reply To: Concatting in variable

    If you're really on SQL 2017, why aren't you using String_Agg()?

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Are the posted questions getting worse?

    Several months ago, someone took over development of our SSRS reports from me.  I had set up all of my reports using shared data sources.  When she took over, she...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Categorize data without an indicator in the table

    This is a standard gaps and islands problem, but it can also be solved with LEAD()/LAG().

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Convert DATETIME to a date in ISO format

    Thom A wrote:

    As I said, yyyy-MM-dd is not ambiguous because (small)datetime treats the value different, and can give the wrong result. For me, If I use the following statement:

    The confusion is...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Using Cursor in DELETE statement

    You're missing a FETCH NEXT inside your cursor.  That being said, you'll be better off in the long run if you fix your trigger rather than trying to work around...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: How can I identify gaps in coverage dates

    I wouldn't use a tally table for this problem.  It's a variation on the interval packing problem.  I believe that this works for the data given, but it might not...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: How can I null out all but the most recent records in this table?

    @Taps wrote:

    Does this work for you

     ;WITH cte_test 

    AS ( SELECT *
    , ROW_NUMBER() OVER (PARTITION BY clientid ORDER BY ClientImportsId...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Date to record zero balance for an account version

    autoexcrement wrote:

    -- Drop target scratch table if it already exists:
    IF OBJECT_ID('tempdb..#OPCantBeBothered') IS NOT NULL
    DROP TABLE #OPCantBeBothered
    ;

    -- Create scratch table:
    CREATE TABLE #OPCantBeBothered
    (
    AccountNo INT,
    VersionNo INT,
    Amount INT,
    StatusDate...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: How to compare three tables using a single column (inner Join is not working)

    It sounds like you want something like this:

    SELECT …
    FROM AccountProfile ap
    WHERE EXISTS
    (
    SELECT AccountNumber
    FROM AbsPlan a
    WHERE a.AccountNumber = ap.AccountNumber
    AND a.AccountStatus = 'Open'

    UNION ALL

    SELECT AccountNumber
    FROM RitPlan r
    WHERE r.AccountNumber =...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Date 'look ahead' and group

    Jason Selburg wrote:

    PIVOT

    PIVOT is too restrictive for what the OP is trying to accomplish, because it only allows one aggregate function, and you need a MIN() and a MAX().

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Date 'look ahead' and group

    Subtract a ROW_NUMBER() from the date to get the group for consecutive dates.  I'll let you work out the details of the ROW_NUMBER() since you said you preferred clues to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Difference Between Datetime per row per item

    Use LAG() or LEAD().

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Unpivot data

    GrassHopper wrote:

    I wpuld like to get the following columns DC, prepaid, collect, WMItem, ItemDescription on the same row by Hdrid + RID. I'm not sure if this is clear or...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Flyway

    Dave Convery wrote:

    Do you have an example of a page that's redirected you to that?

    I'm currently getting that message when trying to view my own profile.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Reply To: Unpivot data

    I don't see anything that requires an UNPIVOT.  What are your expected results?

    Are you trying to create an EAV table?  That's highly discouraged.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 541 through 555 (of 4,085 total)