The having clause happens after the query has completed, so if you are specifying a tablename from your source table then this will get confused
Select Master.PriName as Name, Count(*) as Total ;
From Tran, Master ;
Into Cursor C_GraphData ;
Where Tran.PriCode = Master.PriCode and tran.DatesOn between dDateFrom and dDateUpTo
;
Group By Tran.PriCode
I think this should cure it (note I prefer to use the SQL syntax for between but Between() will work just as well)
HTH
Will
>Hi all:
>
>i am trying to extract data from 2 tables (master and transaction) and store the resultant data in a temporary table in the form of a summary. For example,
>
>Item Nmbr
>
>AAA 10
>BBB 7
>CCC 12
>
>and so on....
>
>The SQL i am using is as below -
>
>Select Master.PriName as Name, Count(*) as Total ;
> From Tran, Master ;
> Into Cursor C_GraphData ;
> Where Tran.PriCode = Master.PriCode ;
> Group By Tran.PriCode ;
> Having Between(Tran.DatesOn,dDateFrom,dDateUpTo)
>
>All is ok in the above SQL statement as long as the Between() clause is omitted but if I query for transaction records BETWEEN 2 dates, i end up getting data for all the dates (even those outside the desired range)
>
>I would appreciate any help in overcoming this shortcoming.
>
>sincere thanks in advance
Will Jones