Calculation of one column on the basis of column from sub query

  • Hi All,

    I want to calculate a summary column on the basis of the column value returning from sub query.

    I want to use the column name which is returning from the sub query in the calculation of other column.

    Could anyone please help me on this.

    Thanks in advance.

    Regards,

    Afreen

  • For example:

    select sum(total) as NetTotal, NetTotal/100 * 3.2 Gross from abc group by a

    I want to use the NetToal to calculate the other column

  • I take it that:

    select sum(total) as NetTotal, (sum(total)/100)*3.2 as Gross from abc group by a

    will not work?

  • Thanks.

    So, please let me the solution for this.

    Thanks in advance.

    Afreen

  • afreenraja (1/23/2013)


    Thanks.

    So, please let me the solution for this.

    Thanks in advance.

    Afreen

    DBA Dom above gave you the basics of the solution. If you want working code, you'll have to give us a sample schema/dataset to work with along with what you've done so far to correct. See the first link in my signature to show you how we'd prefer you to set that up to assist you the most effectively.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

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

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