If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Query to calculate the percentage
Hi,
I have a table with field physical damage (number) and this can be either 0,1 or 2. I need to calculate the percentage of occurrance for when is 1 and 2. How should I do that? Can someone help me? For example. Physical Damage Percentage 0 0 0% 1 2 66.66% 2 1 33.33% Cheers! C |
#2
|
|||
|
|||
Query to calculate the percentage
You didn't give much detail on your table structure. Calculating the
percentage for the entire table should look something liek SELECT [Physical Damage] , Count([Physical Damage])/(SELECT Count( [Physical Damage]) FROM [YourTable]) as Percentage FROM [YourTable] GROUP BY [Physical Damage] wrote in message ups.com... Hi, I have a table with field physical damage (number) and this can be either 0,1 or 2. I need to calculate the percentage of occurrance for when is 1 and 2. How should I do that? Can someone help me? For example. Physical Damage Percentage 0 0 0% 1 2 66.66% 2 1 33.33% Cheers! C |
#3
|
|||
|
|||
Query to calculate the percentage
I need to calculate the percentage for each "row", not the entire
table. Let's say that I have 3 rows, I have 1 row with physical damage value = 2 and 2 rows with physical damage value = 1. So the percentage for physical damage value = 2 should be CountOfPhysicalDamageValue2/ Count(PhysicalDamage) --- 66.66% So the percentage for physical damage value = 1 should be CountOfPhysicalDamageValue1/ Count(PhysicalDamage) --- 33.33% Cheers! C John Spencer escreveu: You didn't give much detail on your table structure. Calculating the percentage for the entire table should look something liek SELECT [Physical Damage] , Count([Physical Damage])/(SELECT Count( [Physical Damage]) FROM [YourTable]) as Percentage FROM [YourTable] GROUP BY [Physical Damage] wrote in message ups.com... Hi, I have a table with field physical damage (number) and this can be either 0,1 or 2. I need to calculate the percentage of occurrance for when is 1 and 2. How should I do that? Can someone help me? For example. Physical Damage Percentage 0 0 0% 1 2 66.66% 2 1 33.33% Cheers! C |
Thread Tools | |
Display Modes | |
|
|