Forum Replies Created

Viewing 15 posts - 2,461 through 2,475 (of 4,087 total)

  • RE: Credits and Debits

    J Livingston SQL (8/12/2016)


    drew.allen (8/12/2016)


    This is actually an improved version of the test harness. I am putting a slight edge on credits, so that they should appear 60% of...

  • RE: Credits and Debits

    This is actually an improved version of the test harness. I am putting a slight edge on credits, so that they should appear 60% of the time. I...

  • RE: Credits and Debits

    I did a quick comparison of J. Livingston's solution and my solution with 10,000 records. J. Livingston's solution did not account for multiple customers, whereas mine did. I...

  • RE: Credits and Debits

    I found a faster solution (at least on this small dataset).

    ;

    WITH totals AS (

    SELECT *, ABS(Amount) AS Amt, SUM(ABS(Amount)) OVER(PARTITION BY Customer, TransactionType ORDER BY Date ROWS UNBOUNDED PRECEDING )...

  • RE: Are the posted questions getting worse?

    First he doesn't post enough data to get from his sample data to his expected results, then when I post as much of a solution as possible given the sparse...

  • RE: How to query a crosstab

    Talvin Singh (8/11/2016)


    Close..but not quiet.

    It was as close as I could get with the original data provided. Incorporating the additional data is fairly straightforward and is left as an...

  • RE: How to query a crosstab

    Your sample data has no OrderID or Qty, so it's not clear how to get those values. I suspect that you want an UNPIVOT, although I prefer the alternate...

  • RE: DateTo parameter not returning correct data

    The problem here is that dates without times represent midnight on that date, so when you are looking for records between your two parameters, you are excluding records that fall...

  • RE: Using Charindex

    No, it's not. Consider the following example:

    -- THIS IS FOR EXAMPLE

    DECLARE @TradeRoles VARCHAR(100)

    SET @TradeRoles = '2,3,5,14'

    -- If the user has role of 1&4 only then Proceed for furhter processing

    IF...

  • RE: query to update a table with XML value

    fafful (8/10/2016)


    Thanks. I made a change to the syntax and the Jobno was not retrieved:

    Update B

    set B.[Processed] =

    case when (T.[XMLResponse].exist('/Boot/ErrorDetails')=1)

    Then 'YES'

    else 'NO'

    End,

    TB.[Jobno] =

    case when (T.[XMLResponse].exist('/Boot/ErrorDetails')=0)

    Then T.[XMLResponse].value('(/Boot/Jobs/Job_entered/@Jobno[1]','varchar(255)')

    End

    from Table_B T inner join...

  • RE: Table with multiple field ID's with different values

    You want to do something like the following, which uses a CTE with a ROW_NUMBER and then filters based on the ROW_NUMBER.

    ;

    WITH dataset AS (

    SELECT *, ROW_NUMBER() OVER(PARTITION BY dataset.user_id...

  • RE: query to update a table with XML value

    There were actually two problems. twin.devil corrected both, but only mentioned one. The second problem is that jobno is an attribute, so you need to use "@" to...

  • RE: Table with multiple field ID's with different values

    I'm sorry, perhaps I should have been clearer. When I said to post data as specified in the link, I meant the method under the title The Correct Way...

  • RE: convert sum of seconds to time h:mm:ss

    As long as you're under 24 hours you can use the following.

    DECLARE @duration_sec INT = 1300

    SELECT DATEADD(SECOND, @duration_sec, CAST('00:00' AS TIME))

    This method should work for any unit of time as...

Viewing 15 posts - 2,461 through 2,475 (of 4,087 total)