Thank you Sergey. This is essentially what I thought would be involved, but your precise syntax is very helpful.
Andrew
>It can be done with a query only if you know in advance all possible values of descrip and code them into SELECT using IIF(). Something like
SELECT t1.*, ;
> IIF(t2.descrip = "A1", qty, 00000) as qty_a1, ;
> IIF(t2.descrip = "b1", qty, 00000) as qty_b1, ;
> ...
> FROM table1 t1 ;
> JOIN table2 t2 on t1.batchid = t2.batchid ;
> GROUP BY 1,2,3
>
You can also build such query dynamicaly based on the list of descrip values in the table2.
>
>>Given the following data structure and relationship, is there a SQL statement that will allow me to extract a crosstab of the QTY field?
>>
>>Table 1.
>>
>>batchid
>>bincount
>>variety
>>
>>Table 2.
>>
>>batchid
>>descrip
>>qty
>>
>>The tables are related on batchid.
>>
>>The desired output format would have a column for each instance of a descrip while summing the qty for that descrip.
>>
>>Thank you for any pointers.
>>
>>Andrew
On a CLEAR day you can see forever.