Skip navigation links

MySQL Forums :: Newbie :: Ratios per row entry


Advanced Search

Ratios per row entry
Posted by: C R ()
Date: April 26, 2012 06:07AM

I have a table with rows similar to the following:
ID    Type    Count
1     A       10
1     B       12
2     A       8
2     B       6
3     A       9
3     B       3
etc.

I wish to calculate the ratio of A and B per ID. For example:
1A / 1A + 1B, or 10/10+12. Then 1B / 1A + 1B, 2A / 2A + 2B, etc.

How can I iterate through this with a SQL query?

P.S. Sorry for the nondescript title, I am having difficulty describing what I am attempting to do.

Options: ReplyQuote


Subject Written By Posted
Ratios per row entry C R 04/26/2012 06:07AM
Re: Ratios per row entry laptop alias 04/26/2012 06:21AM
Re: Ratios per row entry C R 04/26/2012 07:55AM
Re: Ratios per row entry Rick James 04/27/2012 10:57PM
Re: Ratios per row entry laptop alias 04/28/2012 02:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.