KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Aggregate without join issue #2529

Open DVBI opened this topic on on Jan 10, 2022 - 10 comments

DVBI commented on Jan 10, 2022

I have to prepare the query using query builder where I can display only the number records.

For Example, I just want to display the number of users from the user table.

KoolReport commented on Jan 10, 2022

Use this query:

DB::table("users")->count()
DVBI commented on Jan 10, 2022

How it is possible using the query builder? It is applying the group by default to the query

DVBI commented on Jan 10, 2022

Example:

I have a salary table and I want to find the total paid salary using query builder only then Query builder is by default applying group by of primary key of table

KoolReport commented on Jan 10, 2022

Sorry that I have not fully understood your inquiry so could you please write me a simple normal SQL query. I will change it to querybuilder.

DVBI commented on Jan 10, 2022

select count(*) from users;

KoolReport commented on Jan 10, 2022

It is exactly the my query above using querybuider:

DB::table("users")->count()
DVBI commented on Jan 10, 2022

I am talking about https://koolreport.com/examples/reports/visualquery/visualquery/

Sebastian Morales commented on Jan 10, 2022

Ok, it's not very convenient at the moment but you could follow these steps to select count any field of a table with VisualQuery:

1 . In Tables tab: Add a table, select all of its fields.

2 . In Groups tab: Add a group count of the field you want, (no option for count() yet, but count(any field) gets the same result as count()).

3 . Back to Tables tab, deselect all fields.

4 . Click Submit, the query you would get is: "Select count(field1) from table1".

DVBI commented on Jan 10, 2022

What is the permanent solution?

Sebastian Morales commented on Jan 12, 2022

VisualQuery will be improved in the future so that there will be less steps to build your query. Rgds,

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

VisualQuery