>>>>Is there a away to calculate the percentage via a sql statment for the following
>>>>i have for example 100 Laptops and these laptops are being sold by several vendors i want to know the percentage of each vendor for example
>>>>vendor 1 sold 15
>>>>vendor 2 sold 35
>>>>vendor 3 sold 50
>>>>i want to know the percentage of each using the select sql..
>>>>Thanks to all.
>>>
>>>Hi Youssef,
>>>
>>>I think, it's doable, but you have to show us the structure of your tables.
>>>
>>>If you know, that there were 100 laptops sold,
>>>you can use this SQL:
>>>
>>>
select Vendor, Qty/SumQty*100 as percent from yourtable
>>>This assumes, that you know the number of all laptops sold (SumQty) and your table has this simple structure
>>>
>>>Vendor Qty
>>>1 15
>>>2 35
>>>3 50
>>
>>Thanks Nadia for you reply and help, but you are assuming that i know the qty well actually i do not know the qty because i have several vendors and i have also multiple items not laptops only i have copiers toners drums and many other things, that is a child table but it is only one table or the data i need is in that table.
>>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.