views:

17

answers:

0

Hello, please can someone help me?

I'm writing a query for a report to show different results in the factory from the machines. There is speed, efficiency and downtime. The speed and efficiency columns are recorded hourly and the downtime is recorded as and when downtime occurs. This is the code I have to collect the speed and efficiency:

SELECT     T1.SPEED, T1.LineName, T1.SiteName, T1.DateTime, T2.CEEFF
FROM         (SELECT     tblCheckResultInteger.Result AS SPEED, tblLine.LineName,
              tblSite.SiteName, tblCheckResult.DateTime
FROM          tblCheckResult 
WHERE        (tblCheckResult.CheckID = 299)
GROUP BY tblLine.LineName, tblSite.SiteName, tblCheckResult.DateTime,
              tblCheckResultInteger.Result) AS T1 INNER JOIN .............

and the query for the downtime is:

SELECT     tblSite.SiteName, tblLine.LineName, tblCheckResult.DateTime,
                  tblCheckGroup.CheckGroupID, tblCheck.CheckID,
                  tblCheckGroup.CheckGroupName,
                  tblCheckResultInteger.Result, tblProdRun.NoSects
FROM         tblProdRunWHERE     (tblCheck.CheckID IN (6562)) OR
                  (tblCheck.CheckID IN (6563))
GROUP BY tblSite.SiteName, tblLine.LineName, tblCheckResult.DateTime,
           tblCheckGroup.CheckGroupID, tblCheckGroup.CheckGroupName,
           tblCheckResultInteger.Result, tblCheck.CheckID, tblProdRun.NoSects
HAVING      (tblCheckResult.DateTime >= @DateFrom) AND
            (tblCheckGroup.CheckGroupID = 117) AND (tblProdRun.NoSects > 6) AND
            (tblCheckResult.DateTime < @DateTo) AND (tblSite.SiteName = @SiteID)
ORDER BY tblCheckResult.DateTime

The table has 4 columns, one for the LineName, one for Speed, one for Efficiency all with the ordinary fields selection, the DownTime has an expression: =sum(Fields!Result.Value, "DownTime").

When I run the report, if there has been no downtime then the columns Speed and Downtime show the values, but if on that day there was downtime, then no columns appear, can anyone tell me why (Speed and Efficiency columns should always appear as they are recorded hourly). I have it grouped on the LineName so as it shows me 1 average speed and 1 average efficiency per day.

Regards, AW