Sql to show total

Posted on 2011-04-26
Last Modified: 2012-05-11

i have 2 tables

Table one called T which has the following coloums
FCode, FName, N.

Table two called C which has the following coloums:
CC, ConC, Percentage
I        N          30
I        D           40
I        DU        30

for each CC the sum of all percentage should be 100

What I need to do is the following

Sql Statement

to CC where the sum of percentage is not 100, also to show how further off 100 the total of the percentage is.

Please help


Question by:R8VI
    1 Comment
    LVL 4

    Accepted Solution

    Kindly use the following query.

    select CC, sum(Percentage), 100 - sum(Percentage) as 'TotalOff'
    from C
    group by CC
    having sum(percentage) != 100

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now