• Resolved Adel

    (@adells)


    Hallo Scott,

    I could really use your help, please.

    I have a table that contains fields for year, item, a, b, c.

    The JSON is exported to a url.

    Each line in the table is exported as an array {}

    This data needs to be read by another application. In order to do that, I have two options, the first of which would be the neatest.

    To use a simplified example:

    This is what I get when using SELECT year, item, a, b, c FROM Table.
    {1, QWERTY, 10, 10, 20}
    {1, ASDFGH, 15, 15, 30}
    {2, QWERTY, 5, 5, 8}
    {2, ASDFGH, 20, 18, 17}

    First prize is to GROUP BY year, with the following expected output:
    [{1, QWERTY, 10, 10, 20}, {1, ASDFGH, 15, 15, 30}]
    [{2, QWERTY, 5, 5, 8}, {2, ASDFGH, 20, 18, 17}]

    Obviously the output will be nested, that is not a problem ??

    Is there any way for me to be able to do this?

    Alternatively, I need to count unique items.
    When I used SELECT year, count_(year), a, b, c this example would give me a count of 4.
    How should I be structuring the query to count unique values?

    Thank you!! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    I don’t think MySQL itself can do this automatically in a regular query, you’d have to do some potential sub queries. I can’t offer any additional insights here since I haven’t run across a need for this type of querying before, sorry.

    Thread Starter Adel

    (@adells)

    Thanks for the reply, Scott. Appreciate it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Group by’ is closed to new replies.