How do I add a compute sum() on a subqueried column?

  • At the bottom of my script I'd like to get a column sum on a subquery. Every time I do a compute sum(tally) I get an error stating Invalid column name 'tally'. I've tried this with various subquery columns before and I get the same error. Is there a way around this?

  • Oh and each record on the subquery will contain a whole number (basically number of days) that I'd like to keep there and then do a compute sum(days) at the end of the script.

  • That's not really enough info to help you JM. You'll need to post some sample data, your expected results, and an example of the query that you already have that is not giving your the correct results. Table DDL would help a ton too.

    Here's a link to how to create a thread that will get quality help:

    http://www.sqlservercentral.com/articles/Best+Practices/61537/"> http://www.sqlservercentral.com/articles/Best+Practices/61537/

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 3 posts - 1 through 2 (of 2 total)

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