Forum Replies Created

Viewing 15 posts - 2,911 through 2,925 (of 4,085 total)

  • RE: Cross Apply

    g.britton (10/15/2015)


    The supposedly correct answer "The TOP 3 selling products for all customers who have made a purchase." is ambiguous. As I read it, I would expect only three...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Sorting working differently after moving from SQL Server 2008 to 2012

    Kristen-173977 (10/9/2015)


    Personally I'm not keen on that sort of workaround (or the "-1" for the EmpLogin for that matter) such things tend to have side effects and/or break sooner or...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Sorting working differently after moving from SQL Server 2008 to 2012

    Kristen-173977 (10/9/2015)


    Assuming the "Please select" needs to be the first entry? then the ORDER BY needs to perhaps be:

    ORDER BY

    CASE WHEN EmpLogin = '-1' THEN...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: multi-part identifier could not be bound

    You have a main query, a subquery, and a sub-subquery. The table adminfee is only specified within the sub-subquery, but you are trying to reference it in the main...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need help with a simple query from a one to many table relation.

    ScottPletcher (10/7/2015)


    Interesting. Are you sure you don't have those stats backwards? The NOT EXISTS must check the entire table every time to verify that a given row does...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need help putting data into XML format

    Your original query was very close. You're getting Element2 and Element3 twice, because you're specifying them both twice: once in the path() and once in the alias. Instead of...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Updating statment depending on 2 fields

    I think this is what you are looking for:

    refkey = STUFF(

    CASE

    WHEN st.base <> '' and st.qttbase <> 0

    THEN ',B'

    ELSE ''

    END +

    CASE

    WHEN st.cos <>'' and st.qttcos <> 0

    THEN ',C'

    ELSE ''

    END +

    CASE

    WHEN...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Free form text parsing suggestions

    ScottPletcher (9/30/2015)


    Yikes. Here's an alternative that should perform better for you:

    Part of the reason that XML string splitters are inefficient is converting character separated strings to a format that...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Free form text parsing suggestions

    HTML is a subset of XML, it's probably more efficient to treat it as XML and use xquery.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Union Stored Procedure

    UNION applies to sets and stored procedures are not sets, although they may return sets. If you want to union the results of two stored procedure calls, you'll need...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: UPDATE Multiple columns in a CTE

    Since CTEs are essentially single-use views, they follow the same rules as updatable views; specifically

    CREATE VIEW (Transact-SQL)

    Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Counting number of occurances

    Perhaps I'm missing something, but if you want to look specifically at the second ticket, then COUNT is the wrong aggregate. Try the following.

    WITH Ticket_Number AS (

    SELECT ti.person_ID, ticket_date,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: UPDATE using table alias

    I dislike the consistent "U" as a table alias for the table being updated for some of the same reasons that I dislike sequential table aliases, the most important one...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Painful datetime conversion

    Try the FORMAT function. It was added in SQL 2012.

    SELECT FORMAT(vhrgdt, '0000-00-00') + ' ' + FORMAT(vhrgtm, '00:00:00.000'), *

    FROM #Something s

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to choose max of each groups formed by Row_number

    This query can be greatly simplified if you look at it with a different perspective. Instead of the MAX row number within each group, you want a COUNT within...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,911 through 2,925 (of 4,085 total)