I changed the tables and your code
table 1: COMPANY
companynam C,30
ckey N,3
Table 2: DIVISION
div_name C,50
ckey N,3
and in your code:
close tables all
select a.ckey, a.companynam, b.ckey DivID, b.div_name ;
from Company A join Division B on a.ckey = b.ckey ;
group by a.ckey into cursor crsTemp1 nofilter
select a.ckey, a.companynam, b.ckey DivID, b.div_name ;
from Company A join Division B on a.ckey = b.ckey ;
where b.ckey not in (select DivID from crsTemp1) ;
into cursor crsTemp2 nofilter
select * from crsTemp1 ;
union ;
select ckey, space(30) CompanyNam, DivID, div_name ;
from crsTemp2 order by 1, 2 desc ;
into cursor crsResults nofilter
*select crsTemp1
*browse last nowait
*select crsTemp2
*browse last nowait
select crsResults
browse last nowait
I come up with ONLY 1 record even though I have 3 child records.