troubleshooting Question

Show column using sum of two columns Oracle SQL

Avatar of leezac
leezac asked on
Oracle DatabaseSQL
23 Comments1 Solution3414 ViewsLast Modified:
I need to show a column in the results where

  Where the results from this divide    SUM(Case when BALANCE>0 THEN 1 Else 0 end) as "# Parts w/ Bal" -- Assets    (This is a count)      divided into

SUM(Case when BALANCE>0 THEN BALANCE Else 0 end) as "Assets", -- Assets (This is dollar amount)
   

would it look like sum(case when BALANCE>0 THEN 1 Else 0 end) /(Case when BALANCE>0 THEN BALANCE Else 0 end) = "Average"  .  (Dollar amount/ count)= Avg Dollar.  

Do not want to use AVG.   Also need to round to 2 decimal places.



FROM(
      SELECT A.PLAN_ID, PLAN_N,  DVSN_NM, SUM(END_ASET_BAL_A)as BALANCE,  A.AS_OF_D
      FROM dbo.V_SRC_BAL_MO A
ASKER CERTIFIED SOLUTION
Mark Geerlings
Database Administrator, retired

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros