OK, so in LineItems there is a field called BoId, which is BoIdBase in
Details. We can now join those to tables, but you want the Count of some DocID in Details to be a column in the result set. Would this accomplish what you want?
SELECT *;
FROM LineItems;
WHERE &cWhere;
INTO CURSOR LineTemp
SELECT COUNT(DocId) AS NumCleared, BoIdBase ;
FROM Details ;
WHERE NOT EMPTY(AirTime) AND RecType = "A" ;
GROUP BY BoIdBase ;
INTO CURSOR DetTemp
SELECT LineTemp.*, DetTemp.NumCleared ;
FROM LineTemp JOIN DetTemp ;
ON LineTemp.BoID = DetTemp.BoIDBase ;
INTO CURSOR crsResults
>I have a table, LineItems, which is a one-to-many into Details
>
>The first SQL pulls the LineItems for my pre-determined Where
>clause and works fine.
>
>The second SQL counts records from Details which have a value in AirTime,
>into a 2 column cursor. These counts represent the total number of detail
>items, for any given line item, that are cleared
>
>I need to get the LineItems from the first cursor, 'LineTemp', and
>the counts from the second cursor, 'DetTemp', into a table.
>
>How do I do this?
>
> SELECT *;
> FROM LineItems;
> WHERE &cWhere;
> INTO CURSOR LineTemp
>
> SELECT COUNT(DocId) AS NumCleared, BoIdBase ;
> FROM Details ;
> WHERE NOT EMPTY(AirTime) AND RecType = "A" ;
> GROUP BY BoIdBase ;
> INTO CURSOR DetTemp
>>
>Note that both of the above SQL's do work, I just need to combine
>the results so that I see the counts as a line item field.
>
>Thanks
Mark McCasland
Midlothian, TX USA