Forum Replies Created

Viewing 15 posts - 2,521 through 2,535 (of 4,087 total)

  • RE: Getting last good data for each id from each column

    That's because LAG is for a relative position. FIRST_VALUE and LAST_VALUE are for absolute positions. You do have to get a little tricky, because you need to ensure...

  • RE: How do I add a constraint to a column

    CELKO (7/21/2016)


    The bit and varying bit datatypes were deprecated in SQL: 2003 for good reasons. You can read some of this: https://www.simple-talk.com/sql/t-sql-programming/bit-of-a-problem/.

    Yes, but the SQL standards also have a BOOLEAN...

  • RE: Comma separated

    Sean Lange (7/21/2016)


    drew.allen (7/21/2016)


    Get rid of the ISNULL altogether. FOR XML automatically discards null expressions unless the XSINIL directive is specified.

    SELECT DISTINCT STUFF(

    (SELECT ', ' + t2.Name

    FROM #Temp t2

    where...

  • RE: Comma separated

    Get rid of the ISNULL altogether. FOR XML automatically discards null expressions unless the XSINIL directive is specified.

    SELECT DISTINCT STUFF(

    (SELECT ', ' + t2.Name

    FROM #Temp t2

    where t1.ID = t2.ID...

  • RE: SQL query to display the count of combinations

    It's not clear how these results derive from your sample data: specifically, it's not clear why there are two rows for ER instead of 1, and it's not clear where...

  • RE: Junk Dimension Design

    kewlguy13 (7/15/2016)


    Thanks Drew for the comments!

    If I had to design the Junk dimension with these values, what do you suggest.

    What would be Junk Dimension structure?

    Logic: I was thinking about CROSS...

  • RE: Junk Dimension Design

    kewlguy13 (7/15/2016)


    Thanks Guys for the quick response!

    Looking at the target table structure, I could see that Cross Join doesn't fit. That's where I was confused.

    I will try with the EAV...

  • RE: Assistance with CROSS APPLY with multiple tables

    Jabba1963 (7/15/2016)


    My problem in trying to apply (excuse pun !!) the CROSS APPLY approach from details in the article using one table - where I have many... basically its confusing...

  • RE: Junk Dimension Design

    Your design is for an EAV table, not a junk dimension. A junk dimension is derived from the Cartesian product of your attributes so it would look more like

    JunkID

    SubscriptionStatus

    CustomerStatus

    PaymentDesc

    Document

    CaseType

    TransportedTo

    Obviously,...

  • RE: Compare multiple rows in same column

    I found a solution that seems to perform very well given certain pre-conditions.

  • There must be an index on Person/Comp or Person that includes Comp.
  • There must be fewer than 31 (or...

  • RE: aggregate function in subquery

    You can place your CASE expression in a CTE, derived table, or CROSS/OUTER APPLY and then do the SUM in the main query.

    Drew

  • RE: count(null)

    Because you haven't specified a data type for the value NULL, and it can't figure it out from the value itself, so it assigns a NULL data type. It's...

  • RE: Combine rows into one row with line break by querying with XML

    This is a presentation issue and should be left to the presentation layer.

    I am not seeing any strange characters when I run it. XML will entitize CHAR(13) (
), so...

  • RE: how to find number of days between successive visists?

    cad.delworth (7/12/2016)


    drew.allen (7/11/2016)


    The reason that you were getting bad results is that your "dates" aren't really dates. They're strings, so they sort alphabetically.

    The OP didn't specify the data type...

  • RE: Multiple joins to same table in view

    kobi.burkis (7/12/2016)


    Hi

    Thank you drew.allen for a quick response.

    I don't have an aggregate function to apply on the table for pivoting.

    You actually do. If you can guarantee a...

  • Viewing 15 posts - 2,521 through 2,535 (of 4,087 total)