Forum Replies Created

Viewing 14 posts - 1 through 14 (of 14 total)

  • RE: Display Sum() value based on Grouped datafield value

    Hi

    I've found a solution but would still like to learn how to optimize it.

    This is what's worked for me. I've changed the date as you suggested and for my...

  • RE: SUM function for subquery

    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!

  • RE: SUM function for subquery

    This is what worked for me. Thank you very much.

    ;WITH CTE AS

    (SELECT Top 1 Amount+VATAmount AS TOTAL

    FROM FAAccKitty WITH(NOLOCK)

    inner JOIN FAAccWinners on FAAccKitty.PlaceID=FAAccWinners.PlaceID

    INNER JOIN Reservations WITH(NOLOCK) ON (Reservations.PlaceID...

  • RE: SUM function for subquery

    Thank you I have got it working now with the CTE the ABS() function was missing.

    I will however try to implement your other suggestions as they seem quite interesting

    Thank you...

  • RE: SUM function for subquery

    Appending the table name didn't work the strange thing is though if I use

    just the SELECT from your code I get all my previous values coming as negative.

    SELECT Amount+VATAmount...

  • RE: SUM function for subquery

    Please ignore my second data structure post I thought the first didn't get posted.

    Will try appending the table name now

  • RE: SUM function for subquery

    Not sure why I'm getting the negative SUM total because there are no

    negatives in the dataset.

    I've been able to get the data structure as requested if that helps

    SET ANSI_NULLS ON

    GO

    SET...

  • RE: SUM function for subquery

    As I said I'm getting negative value for total but I don't have any negative values in

    the dataset.

    I've been able to get the data table structure if that helps.

    SET ANSI_NULLS...

  • RE: SUM function for subquery

    This works if I take out the TOP 1. I'm getting the right total value but it comes out as a negative?

    The Amount and VatAmount fields are both set to...

  • RE: SUM function for subquery

    The desired output is all the amounts added up to give one value

    Without the SUM function I just have like 9 records for example like this

    2400.00

    2640.00

    1900.00

    478.80

    750.00

    600.00

    1030.00

    980.00

    425.00

    I just want these added...

  • RE: SUM function for subquery

    Getting syntax errors for this

    Msg 102, Level 15, State 1, Line 5

    Incorrect syntax near ')'.

    Msg 156, Level 15, State 1, Line 11

    Incorrect syntax near the keyword 'AND'.

    Msg 156, Level 15,...

  • RE: SUM function for subquery

    Getting these

    Msg 102, Level 15, State 1, Line 2

    Incorrect syntax near '='.

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near ')'.

    Msg 156, Level 15, State 1, Line 9

    Incorrect syntax...

  • RE: Using Alias in Where

    Thank you that looks like it might do the trick.

    And no I'm not aware of the pitfalls of No Lock could you please elaborate?

    Also what is a CTE. Is this...

  • RE: Selecting highest value from duplicate records

    Are you kidding me?

    I just put this up and you give me a solution that works.

    This site rocks

    Thanks

    My apologies as well I think I posted this question in the wrong...

Viewing 14 posts - 1 through 14 (of 14 total)