0

I want to count certain Esports events rolling up results by tournament, tournament stage, last 5 and last 10 games, all matches.

I'd like to get a single query that I could put into materialised view - new events happen not too often, so even a few sec query would be perfectly fine for our db.

The picture of what I want to get:

enter image description here

Metrics are very different (tower kills, dragon kills, first tower kills, etc) and I would like avoid copy-paste as much as I could.

This logic could be easily implemented within application code, but I'd like to give the database a try.

Unfortunately, I don't have any working code yet, as the only solution I'm aware of today - create unions with kind of copy-pasted select statements.

I'm looking for something like GROUP BY ROLLUP tournamentId, {limit 5}, {limit 10}, but it seems there is no a very straightforward way to do this.

Any hints on how this could be implemented?

Thanks!

  • Please take a few minuets to take the [Tour](https://stackoverflow.com) and review [ask]. Then update your question to include sample data, actual table definition (ddl scripts), the expected results of that data and what you have tried, all as text - **no images**. Even better create a [fiddle](https://dbfiddle.uk/). Further clearly describe what you are attempting and where you are having issues. Finally, show what have you tried? – Belayer Sep 11 '22 at 23:48
  • I've tried... Nothing? Because I don't know how to do it (GROUP BY ROLLUP seems not be allowing kind of LIMIT clauses), so this is why I'm asking for help. I need an advice or a direction to work not, and not a direct answer to my problem. Anyway, as I see from the previous questions (with a well-described problems, almost working solutions, test data and everything else that people have when they know how to do it) I see that it is almost impossible to get help on a complex problem here. – Bohdan Shulha Sep 12 '22 at 13:28
  • Also, I don't want others to spend a lot of time solving my problem, so I don't ask for any completed 50 LOC SQL (one of the reasons why didn't I put any kind of schema into the question). I'm looking for just a tiny hint on how to add an extra rollup condition. – Bohdan Shulha Sep 12 '22 at 13:38

0 Answers0