Support » Plugin: Inline Google Spreadsheet Viewer » Group By – Where, Having, or Multiple Queries

  • Resolved premierbaseballkc

    (@premierbaseballkc)


    I have searched but I cannot find an answer to my problem. Please Help!

    In google query language there is no HAVING clause like there is in SQL, and you cannot do a WHERE clause when using a GROUP BY clause.

    I found the solution for this when working in a spreadsheet by doing multiple queries thanks to this page: https://productforums.google.com/forum/#!msg/docs/SBOoz-3Gd0s/cHlDECkCCQAJ

    But I don’t see how I can do a query like that in the inline google spreadsheet viewer.

    My specific problem is that I’m working on a baseball tournament website. I want when you go to a team’s page to use this plugin to show their current record and total runs scored and total runs against from the tournaments they’ve played in.

    I planned to have a spreadsheet that lists all tournament games from all of my tournaments.

    So on the team page I need to do a query that only selects the rows for games where that specific team played in so I need to do a WHERE clause, but when I do a where clause then I can’t COUNT the number of wins or SUM the runs scored for that specific team.

    I have this query written in my spreadsheet and it works fine, I just need a way to have the inline google spreadsheet viewer do the same thing:
    =query(query(A:H, “select A, B, C, D, E, F, G, H WHERE (C = ‘Mavericks’) and (A = ‘2019’)”), “select Col1, sum(Col5), sum(Col6), sum(Col7), sum(Col8) group by Col1 LABEL sum(Col5) ‘Wins’, sum(Col6) ‘Losses’, sum(Col7) ‘Runs Scored’, sum(Col8) ‘ Runs Against'”)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Meitar

    (@meitar)

    I have this query written in my spreadsheet and it works fine, I just need a way to have the inline google spreadsheet viewer do the same thing

    Don’t do the same thing in two places, just perform the query in the Sheet, then select the results?

    But it is dependent on which team page the user is on. In my example the team page is the Mavericks so I only want to get their results.

    I will have hundreds of teams and more added throughout the season, and this is just one example of where I’m needing a solution like this, it will be useful for other places on my site as well, so I can’t have all the queries prebuilt in the spreadsheet, I’m going to need the IGSV select pass through some variables like team, year, season, tournament etc…and that will query one large set of data so I need the WHERE or HAVING or a way to pass multiple queries or some way of being able to do a group by for specific instances in a large group of data.

    Sorry if I’m not explaining the situation clearly, and by the way, thank you for responding.

    Plugin Author Meitar

    (@meitar)

    it is dependent on which team page the user is on. In my example the team page is the Mavericks so I only want to get their results.

    Okay. So?

    https://wordpress.org/support/topic/use-part-of-website-page-url-in-a-query/#post-9784135

    Did you, like, not search this forum or read this plugin’s description before you started this thread?

    I can’t have all the queries prebuilt in the spreadsheet

    If that’s true, why are you using a Spreadsheet plugin? You seem convinced you need more capabilities than Google Sheets offers, and also convinced you want to use Google Sheets as the database for your project, while making it my problem that you can’t have your cake and eat it, too.

    Did you, like, not search this forum or read this plugin’s description before you started this thread?

    As I mentioned above I did search…for a long time…I’m not asking how to pass a variable through the query…

    You seem convinced you need more capabilities than Google Sheets offers

    I wasn’t convinced of anything, I was asking a question and wanted to make sure I gave you sufficient information because I didn’t know if what I wanted was capable or not with the plugin.

    I see that what I want to do is not capable with this plugin. Thank you for your time.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.