Help with SQL Query

  • It's preferred to copy-paste schemas, code etc into your post instead of as an attachment. Many of us don't open attachments due to virus risks. Use the "Insert/Edit code sample" option.

  • Hi,

    Sorry rookie mistake, I edited the post to show the table info, hopefully that helps..Thanks

     

  • Ignore "code" and  GROUP BY on Company ID# ?

  • Hogie503 wrote:

    Hi,

    Sorry rookie mistake, I edited the post to show the table info, hopefully that helps..Thanks

    You've been around long enough to know this.  In my signature is a link that provides instructions.

    Does this work?

    WITH CTE
    AS
    (
    SELECT
    YEAR,
    COmpany,
    CompanyID,
    Sum(TotalAmount), TotalAmount
    MAX(Bid_Limit) BidLimit
    FROM Table
    GROUP BY
    YEAR,
    COmpany,
    CompanyID
    )

    SELECT
    YEAR,
    COmpany,
    CompanyID,
    TotalAmount,
    BidLimit.
    BidLimit - TotalAmount Results
    FROM CTE

     

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Thank you.. Really appreciate the help...

Viewing 5 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply