Calculating Totals

  • I have two tables called Resource, and Comment

    table structure is

    1)Resource

    EntryNoint

    ResourceNovarchar(50)

    JobNovarchar(50)

    Quantitydecimal(18, 0)

    2)comment tablr

    CommentNoint

    CommentLineNoint

    commentntext

    Relation between two table is EntryNo in Resourse table and the commentNo in comment table are the same and one entry number will have n number of comment in comment table

    my job is to create a .rdl report with this two bale with using below query

    SELECT Rsource.EntryNo, Rsource.ResourceNo, Rsource.JobNo, Rsource.Quantity, Comment.comment, Comment.CommentNo,Comment.CommentLineNo

    FROM Rsource left outer JOIN

    Comment ON Rsource.EntryNo = Comment.CommentNo

    its getting fine but when iam caculating the total quantity for perticular entry no the total iam getting is wrong because of if quantity of perticular entryno is say 40 and this entry no is having 4 comments in comment table then the total quantity is 200(it is adding 4 times because i have 4 comments againest this entry no)

    Please suggest me how to get the exact total with out any duplication

  • Duplicate post. No replies to this thread please. Direct replies to:http://www.sqlservercentral.com/Forums/Topic673017-147-1.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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