• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Creating a dynamic pivot table visualization for a SQL beginner??

arcadeicons

Member
I need to create a scoreboard for my web site that will show the results of a league as scores are entered. Our (Arcade Gaming) leagues involve playing various different games in a tournament and awarding points based on the players ranking by score for each game.

I've looked at the pivot plugin but it doesn't seem like it 's going to help creating actual visualizations.

I have all of my score in my table already _submit_score
id
create_time
created_by
collectiontype
gameID
gamescore
player
eventID
playerID
userID
date_time
sim_players
tournID

I need to create a pivot visualization with:
- X-Axis - Game names
- Y-Axis - Ranking
- Cells - Concatenated info containing the player name, avatar and their single highest score only for that particular game. (Players will play the same game many times during a tournament)

I also need to do some math in the background that assigns points per player per game based on their rank position per game rather than their actual score (yep I know this is a separate function)

I'd hoped there would be some handy dandy wizz-bang Joomla plugin that would help me achieve this with my tiny knowledge of SQL but I haven't found anything so far.

website is here if seeing it helps make more sense http://www.ArcadeIcons.com
 
I think you might be able to do it with a MySQL view. "Views" are basically dynamic tables in MySQL, which are created from any valid MySQL query that produces a set rows.

However, as MySQL doesn't have any kind of "pivot" function, producing the query is a bit difficult. Here's an example:

http://stackoverflow.com/questions/12004603/mysql-pivot-row-into-dynamic-number-of-columns

... which has a working MySQL Fiddle example you can look at. You'd have to do the first approach, using the aggregate function with case statements, unless it's possible to create MySQL views using stored procedures (I honestly don't know). But that's only really viable if you know the games involved, and they don't change.

If that approach works for you, you can then create a view by doing "CREATE VIEW your_view_name AS SELECT ..." (so the query producing the pivot goes where the ... is).

Then you can build a (read only) Fabrik list on that view, as if it was a real table.

Other than that, the only other way is to do it by hand. Wouldn't be too awfully hard to code up, and use something like Sourcerer to embed the code in an article to produce your output on the fly. Well, for me anyway. But obviously that'd be hourly billed custom work.

-- hugh
 
Yeah the game amounts, titles and the players change constantly, I am using one page with a few variables passed in the URL to filter out tournament games and attendees to show the results the specific tournament being viewed.

As much as I hate to do it I may have to ask a friend to just code this part for me.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top