April 29, 2008 at 12:09 pm
I can't seem to wrap my head around this!!
tblReturn: colAcct, colSector, colAdate, colMkt
I want to return this percentage:
(colMkt where colSector = 02 / colMkt where colSector = TF)
Any help pointing me in the right direction would be gladly appreciated.
April 29, 2008 at 12:14 pm
select sum(case when colSector ='02' then colMkt else 0 end)/sum(case when colSector ='TF' then colMkt else 0 end) as percentage
from tblreturn
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
April 29, 2008 at 3:12 pm
To avoid "Division by 0" error it's better to use "else NULL" instead of "else 0".
_____________
Code for TallyGenerator
April 29, 2008 at 3:17 pm
Sergiy (4/29/2008)
To avoid "Division by 0" error it's better to use "else NULL" instead of "else 0".
correct! wasn't paying attention.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
April 30, 2008 at 7:02 am
Thanks for your help- I was able to get the info I needed.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply