delphi – Distinct count no fastreport

Question:

How to make a Distinct Count in FastReport ?

I have the report:

name – sex
John – m
John – m
Mary – f

In normal Count , the result would be 3, but I want one that takes only the amount of lines that do not repeat the name field. In this case, the result would be 2.

Can anyone help me? This is just an example. I can't do a group by in the db because I have several fields.

Answer:

As far as I know you don't have anything done for this on FastReports. The count function has no parameters to give you just the distinct.

The best thing is to do it in the query, if you don't want to do the group by you can always do something like

Select a.nome,a.sexo,(Select count(*) from pessoas b where b.nome=a.nome) 'CountDistinct' from pessoas a Where condicao

It might be a little overkill, but for simple queries, I'd say it worked

Scroll to Top