Forum Replies Created

Viewing 15 posts - 3,826 through 3,840 (of 10,144 total)

  • RE: join 2 tables without duplicate rows

    Here's an alternative to Abu Dinas' suggestion;

    SELECT

    b.dbPatID,

    b.dbPatFirstName,

    b.dbPatLastName,

    x.dbStaffLastName,

    b.TotTot

    FROM EPSAgedBalances b

    CROSS APPLY (

    SELECT TOP 1 dbStaffLastName

    FROM EPSAllContracts c

    WHERE c.dbPatID = b.dbPatID

    ) x

    WHERE b.TotTot < 0

    Not...

  • RE: Unable to convert character to datetime

    SELECT CounterDateTime = CAST(CAST(CounterDateTime AS CHAR(24)) AS DATETIME)

    FROM (SELECT CounterDateTime = '2013-12-30 12:09:00.123' + CHAR(10)) d

    -- Msg 241, Level 16, State 1, Line 1

    -- Conversion failed when converting date and/or...

  • RE: Flatten hierarchy

    Try this - it's called a CROSSTAB query:

    SELECT id,

    LevelDesc1 = MAX(CASE WHEN levelid = 1 THEN leveldesc ELSE NULL END),

    LevelDesc2 = MAX(CASE WHEN levelid = 2 THEN leveldesc ELSE NULL...

  • RE: Stored Procedure OUTPUT param VS RETURN VS SELECT

    The return value of a stored procedure is traditionally used for this:

    RETURN 0 if the procedure ran successfully

    RETURN -n if the procedure failed.

    ALTER PROCEDURE TestOutput @Outcome CHAR (4)

    AS IF...

  • RE: SUM function for subquery

    BlackIceAngel (12/31/2013)


    That is perfect thank you

    The solution needs the SUM() function though for my requirements,

    SELECT SUM(ABS(k.Amount + k.VATAmount)) AS TOTAL.

    Love this site!

    So long as you are aware that SUM()...

  • RE: Are the posted questions getting worse?

    dwain.c (12/31/2013)


    ChrisM@Work (12/31/2013)


    Stefan Krzywicki (12/30/2013)


    wolfkillj (12/30/2013)


    Stefan Krzywicki (12/30/2013)


    wolfkillj (12/30/2013)


    GilaMonster (12/30/2013)


    wolfkillj (12/30/2013)


    is there really a performance problem or are you just "tuning" the query as a knee-jerk response to seeing a...

  • RE: SUM function for subquery

    You're welcome, thanks for posting the final query. If it works for you and generates the results you want, then that's good and you're probably done - but I'd recommend...

  • RE: SUM function for subquery

    Can you post your solution please? It's closure for your thread, offers closure for those who have helped you, and may help others who stumble upon this thread whilst seeking...

  • RE: how to calculate no.of .months billed customer

    raghuldrag (12/31/2013)


    i need the output like

    for example 2013-04-01 is in table my expectation output is 04-2013 (extract month with year)......

    Is '2013-04-01' a date datatype or a string datatype?

    You are...

  • RE: Stored procedure taking too long to run

    The good ol' ROW_NUMBER() trick might be worth a try. A few tests on a similar-sized table here indicates relative costs of 20% for the table scan, 30% for the...

  • RE: How to count months for these table with inner join of sql server 2000?

    Split thread. Please post replies to the original thread here, where you will obtain background information and progress to date.

  • RE: How to split the date format into month with year?

    Split thread. Please post replies to the original thread here, where you will obtain background information and progress to date.

  • RE: SUM function for subquery

    Here's the very first query from your very first post, reformatted and with table aliases applied for readability:

    SELECT

    SUM(Amount=ABS((

    SELECT Top 1 Amount + VATAmount

    FROM FAAccKitty k1 WITH(NOLOCK)

    Where k1.PlaceID...

  • RE: How to use the subquery column highglighted in the GROUP BY

    eobiki10 (12/30/2013)


    Thanks Chris for responding to this query. I have been able to solve the problem.

    EO

    Can you post your solution please? It provides closure for this thread and for those...

  • RE: Are the posted questions getting worse?

    Stefan Krzywicki (12/30/2013)


    wolfkillj (12/30/2013)


    Stefan Krzywicki (12/30/2013)


    wolfkillj (12/30/2013)


    GilaMonster (12/30/2013)


    wolfkillj (12/30/2013)


    is there really a performance problem or are you just "tuning" the query as a knee-jerk response to seeing a scan in...

Viewing 15 posts - 3,826 through 3,840 (of 10,144 total)