
December 27th, 2007, 11:56 AM
|
|
Registered User
|
|
Join Date: Dec 2007
Posts: 1
Time spent in forums: 23 m 57 sec
Reputation Power: 0
|
|
Help with sql plus commands min, max and avg
Hi there, I am a BA / TA assigned to sql queries for the first time. I do have a query to search for min, max and avg for one or two fields, please see sample below. I need to run the query for more than two fields, any ideas?
Here is the sample I am using for two fields:
select min(CASE BAL1 WHEN 0 THEN BAL2 ELSE BAL1 END),
max(CASE BAL1 WHEN 0 THEN BAL2 ELSE BAL1 END), SUM(CASE BAL1 WHEN 0 THEN BAL2 ELSE BAL1 END), count(*),
avg(CASE CASE BAL1 WHEN 0 THEN BAL2 ELSE BAL1 END)
FROM TALBE.BALALL;
I need to run the same query for five different balances, how can I do that?
Thanks,
Frank Vasquez.
|