>ok i'm sorry for not making myself clear. problem for me is i don't know at design time how many fields will appear in my report. like this cursor depends on the type of leaves of all employees. there are like 20 type of leaves, and i'm trying to get rid of those leaves that were not used for the month.
>
>say, only VL and SL were availed by all employees, only VL and SL should appear in my cursor.
>
>i'll take a look at the solutions you gave me, thanks! =)
Evelyn,
Ok, you mean : how many different values for Leave
Think both the solutions 1 && 2 deal with that. Look at the select after the 'union all'.
To be on the safe side you could write
select tt_emp as emp_, ;
year(tt_date) as year_, ;
month(tt_date) as month_, ;
0 as grp, ;
day(tt_date) as day_, ;
tt_leave as leave_, ;
$1 as count_ ;
from test ;
into cursor ReportCursor2 ;
union all ;
select tt_emp as emp_, ;
year(tt_date) as year_, ;
month(tt_date) as month_, ;
1 as grp, ;
0 as day_, ;
tt_leave as leave_, ;
ntom(count(*)) as count_ ;
from test ;
group by 1,2,3,4,5,6 ;
having !empty(count_) ;
order by 1,2,3,4,5
Gregory