Skip to content
Advertisement

Using SQL table structure for points scoring

I am currently playing in a Fantasy Football league and I’m attempting to use some stats to make some informed decisions for my team.

At the moment, I have a table with some historical player performance data, with each row of the table being one player’s output in one game, as below:

My league has a specific points scoring tariff, which I aim to store in another table, as below:

From the two tables above, I aim to build a view that will calculate the points scored for each game, which would like the below:

[Where 28 is (200*0.04) + (5*4) and 26 is (350*0.04) + (3*4)]

My question is, how do I store the points tariff data? My data obviously has more than 2 metrics so I’d prefer not to type in the number manually for each of the metrics. I’m sure there’s an easy way to do it but I just can’t work it out. Thanks!

Advertisement

Answer

I think you want:

and:

Then you can join the tables and aggregate:

Actually, I suspect that you also want a Players table and a MetricId column in the metrics table. That way, you don’t need to repeat strings in different tables — something where typos can throw off your results.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement