Hello everyone. I am well versed in VBA and am fairly proficient within PLSQL but I have run into somewhat of a roadblock.
What I am trying to accomplish is a count of variables within multiple case statements to give an ultimate count at the end.
Example case statement:
Select... *snip*
CASE
WHEN SUM(A.value1 + B.value2) >= 20 THEN
'High'
WHEN SUM(A.value1 + B.value2) BETWEEN 10.01 AND 19.99 THEN
'Medium'
ELSE
'Low
END AS "Rank"
I've attempted to declare 3 variables (x, y, z) as numbers and add in the following to each of my case statements such as:
Declare
x number := 0;
y number := 0;
z number := 0;
Begin
Select... *snip*
CASE
WHEN SUM(A.value1 + B.value2) >= 20 THEN
'High'
x = x + 1
WHEN SUM(A.value1 + B.value2) BETWEEN 10.01 AND 19.99 THEN
'Medium'
y = y + 1
ELSE
'Low
z = z + 1
END AS "Rank"
... *snip*
end;
However I keep running into various errors. Is the above feasible where I can keep a running count across multiple case statements and provide the results in the end. Ideally I would like to see something along the lines of:
Name - Case 1 - Case 2 - High Count - Med Count - Low Count
John - High - Medium - 1 - 1 - 0
Sally - Medium - Medium - 0 - 2 - 0