Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Derived table not working properly
Tue, May 4 2010 8:25 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I'm trying to get the counts as shown below (ie totals and totals for a date range). Currently I'm experimenting in EDBManager

SELECT
_LastResult, Count(*) AS ProjectCount, DatedCount
FROM Calls                               
JOIN               
(
SELECT
_LastResult,Count(*) AS DatedCount
FROM Calls
WHERE
(_LastResult <> '-' AND _LastResult IS NOT NULL)
AND
_LastAttempt BETWEEN :Starter AND :Ender
GROUP BY _LastResult
) DC ON _LastResult = DC._LastResult
WHERE
_LastResult <> '-' AND _LastResult IS NOT NULL
GROUP BY _LastResult
ORDER BY _LastResult


I was using b9 and with that ProjectCount was correct but the DatedCount figures were incorrect. I installed b13 and now I don't get any figures for either ProjectCount or DatedCount.

I've tried both with and without parameters.

In b13 this

SELECT
_LastResult,Count(*) AS DatedCount
FROM Calls
WHERE
(_LastResult <> '-' AND _LastResult IS NOT NULL)
AND
_LastAttempt BETWEEN DATE '2010-04-01' AND DATE '2010-05-04'
GROUP BY _LastResult

gives zero rows

but

SELECT
_LastResult, COUNT(*) AS DatedCount
FROM Calls
WHERE
(_LastResult <> '-' AND _LastResult IS NOT NULL)
AND
_LastAttempt BETWEEN :Starter AND :Ender
GROUP BY _LastResult

with Starter set to 2010-04-01 and Ender set to 2010-05-04 (ie as above) gives 22 rows

HELP!!

Roy Lambert
Tue, May 4 2010 1:31 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I think I may have "lost" a load of records of the end of the table. I'm loading back from the live database and I'll retry.

Roy Lambert
Tue, May 4 2010 2:05 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

And when I recovered the records I found I, being a moron, was using the wrong table in the derived table. All working now.

Roy Lambert
Image