>I have a header table and a child table.
>
>Not all header records have a child record.
>
>I want to pull all headers and also a column with the count of child records.
>
>What I have isn't working. Using VFP 9:
>
>
>SELECT mh.Caption, mh.Icon, COUNT(mi.*) AS Total;
> FROM MenuHead MH;
> JOIN MenuItems mi on mi.Parent = mh.id;
> GROUP BY mh.Caption, mh.Icon;
> INTO CURSOR Temp1
>
>
>Anyone?
>
>Thanks
VFP9 right?
if so:
SELECT mh.Caption, mh.Icon, NVL(TblChild.Cnt,CAST(0 as int)) AS Total;
FROM MenuHead MH;
LEFT JOIN (SELECT Parent, COUNT(*) AS Cnt;
FROM MenuItems;
GROUP BY Parent) AS Mi;
on mi.Parent = mh.id
INTO CURSOR Temp1
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.