Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using a view to compute columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-10-29 : 23:47:11
kevin writes "Hello,

I am developing an application for children to create their own baseball card on the net. I am using SQL 7.0 for my database.
My question:
Is using a view the best way to compute their batting avg, slugging percentage, seson totals
.etc. This view will run off the bas etable that stores their
hitting information. ie (at_bats,singles,doubles,triples, homeruns)
My view looks something like this:

create view player_stats (player_id,season_id,num_hits,bat_avg)
as
select player_id,season_id,
sum(num_singles +
num_doubles +
num_triples +
num_hr
),
sum((num_singles +
num_doubles +
num_triples +
num_hr) / at_bat)
from Player_at_bat
group by player_id,season_id

I hope you can help

Thanks
Kevin"
   

- Advertisement -