Youssef,
Which Report Writer you're using? How do you call it?
Assuming it's a VFP Report Writer and you call it from the button on the form, just put this code before calling a report:
local lnSelect
lnSelect=select()
report form YourReport to printer noconsole
use in select('curFinal')
use in select ('curSummary')
select (lnSelect)
Don't use aliases in your report, just field names. It will work.
>>>The Structure of the table is as follows
>>>Type = and for example laptops copiers and many others
>>>Qtyout = and that is the qty withdrawn from our store
>>>Vendor = Customers that are wholesellers for our laptops and copiers.
>
>It worked perfectly Nadya without any modifications, is it possible to put that sql statment in a report..??
>Thanks A Lot..... Well Done....
>Regards
>
>
>>>
>>>i want to know the percentage of each vendor with accordance to the whole qty i sold i will try to give you a close example
>>>I have sold about 250 Laptops
>>> 1350 Copier
>>> 6800 Toner
>>>of course these items where sold to different vendors, what i want to know is
>>>Vendor 1 sold 50 laptop and 400 Copier and 1400 Toner what is the percent of each item concerning that vendor for every type... Is that Clear
>>>Thanks for Your help, i hope i made my self clear...
>>Yes, now it's clear and actually this is what I expected :)
>>
>>Ok, let's try:
>>
select type as Item, sum(QtyOut) as SumQtyOut from yourtable;
>> group by 1 into cursor curSummary
>>
>>select vendor, type, sum(QtyOut/SumQtyOut*100) as Percent ;
>> from yourtable inner join curSummary on YourTable.Type=curSummary.Item ;
>> group by 1,2 ;
>> into cursor curFinal
>>
>>This is from the top of my head and not tested, so may not work, but it will give you the idea.
If it's not broken, fix it until it is.
My Blog