CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Jan 2005
    Posts
    34

    Why this isnt work incorrect?

    I have database with tables like this:
    http://img244.imageshack.us/img244/7411/a5if.jpg

    I want to know how many cash is floating in contract
    A report must look like that:
    ID_PK | SUM(costs.Value) | SUM(foreincosts.Value) | SUM(service.Value)

    I have example data like this:
    Contract
    http://img200.imageshack.us/img200/1673/19vp.jpg

    Costs
    http://img179.imageshack.us/img179/8407/23dm.jpg

    ForeinCosts
    http://img105.imageshack.us/img105/5049/23zd.jpg

    Service
    http://img169.imageshack.us/img169/3752/40mj.jpg

    Query looks like this.


    Code:
    SELECT 
         contract.HowMutch,
         SUM(costs.Value) AS CostSum,
         SUM(foreincosts.Value) AS FCostSum,
         SUM(service.Value) AS ServSum,
         contract.ID_PK
       FROM
        contract
        LEFT OUTER JOIN costs ON (contract.ID_PK=costs.IDcontract_FK)
        LEFT OUTER JOIN foreincosts ON (contract.ID_PK=foreincosts.ID_Contract_FK)
        LEFT OUTER JOIN service ON (contract.ID_PK=service.ID_Contract_FK)
       GROUP BY
         contract.ID_PK
    But this is incorrect results. What is wrong with this query??
    Please help.
    http://img280.imageshack.us/img280/2450/55jm.jpg
    Last edited by beeper; July 20th, 2005 at 09:52 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured