Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL query help
Pete,
It wasn't entirely clear from your message what you wanted, so I guessed
that you wanted your output to be similar to what you are getting now,
except that states without snowfall should appear in the output.
So I used the vull value function with a default of 0 to display states that
didn't have any weather reported, then summed up the total number of snowy
days using the decode.
... hope this helps, but let me know if you needed something entirely different.
Select sa_states.state, sa_states.area,
nvl(sum(decode(sa_stat.prec, 'Snow', 1, 'Rain', 0 )),0) as snow
from sa_states, sa_stat
where sa_states.state = sa_stat.state(+)
group by sa_states.area, sa_states.state
order by sa_states.area;
-Tom Received on Tue Mar 02 1999 - 02:34:09 CST
![]() |
![]() |