Performing a query with group by and count

I am looking to perform a query from a company table with a category table. I’m attempting to understand how to get a list of the number of companies per category. (this is a simple one to many relationship).

Any insight on how to do this would be greatly appreciated. I’ve spent tons of time looking into the docs and can’t make heads or tails out of it. (I have also looked into the Agile Reports, however, it seems like it is not up to date with the recent version of Agile, so I’m a bit stuck!)

Hello, you might want to consider GroupModel from the ATK4 Report.

Not sure if it works with the latest version though.

Thanks Zak… tried to install with composer but I was getting issues, so I think you’re right there seems to be some compatibility issues.

You can try with this in composer.json

{
  "minimum-stability": "dev",
  "prefer-stable": true,
  "require": {
    "atk4/ui": "dev-develop#1ca8f16 as 1.7.1",
    "atk4/data": "dev-develop#073dfb1 as 1.4.1",
    "atk4/dsql": "dev-develop#7f85985 as 1.2.5",
    "atk4/schema": "dev-develop#e99a481 as 1.1.6",
    "atk4/mastercrud": "dev-develop#3deb6d8 as 1.1.0",
    "atk4/audit": "dev-develop#ab5fde8 as 1.1.1",
    "atk4/chart": "dev-develop#ddbd752 as 1.0.0",
    "atk4/report": "dev-develop#8ed1b4b",
  },
  "autoload": {
    "psr-4": {
      "yourprojectname\\": "lib/",
      "atk4\\report\\": "vendor/atk4/report/src/"
    }
  },
  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "atk4/report",
        "version": "dev-develop",
        "type": "package",
        "source": {
          "url": "https://github.com/atk4/report.git",
          "type": "git",
          "reference": "develop"
        }
      }
    }
  ]
}