SQL Question: Get Ratio Out of Two Rows
aDBAMay 1 2013 — edited May 1 2013My data in a table looks like below:
ID Name Value
----------- ------------------- ----------------
1 n1 1234
1 n2 2345
2 n1 3456
2 n2 4567
....
I need to get ratio (value of n1)/(value of n2) for each ID. So my results are like
ID Ratio
---------- --------------
1 0.58
2 0.75
.....
I can write PL/SQL to get the results. But I am wondering if a simple SQL can do that too.
Thanks.