In hour application we have on query like this in PostGreSQL
select count(distinct vendor), count(customer) from table
This query counts the number of unique vendors and count the total number of customers, in my sample table it returns :
vendor customer
------- ---------
7 2814
It is the response that I need.
Now using the same date in a DBF table, I made the following tests...
This same query running in VFP 9.0 generate the same response that PostGreSQL
vendor customer
------- ---------
7 2814
With HXTT , I found a thread in the forum that says to use Distinct on ( Cont distinct do not work) , the I created the following related query
select distinct on (vendor) , count(vendor) , count(customer) from table
And it returns
vendor customer
------- ---------
6 7
How can I wrote a query to obtain the "correct" answer with HXTT ?
Thanks for your support.
|
According to your request, v4.2.005 supports DISTINCT parameter for the aggregate functions of COUNT, SUM, and AVG. You can use the following sqls:
select (select distinct on (vendor) count(vendor) from table1), (select count(customer) from table1)
select count(*),sum(atempcolumn) from (select count(customer) as atempcolumn from table1 group by vendor)
select count(distinct vendor), count(customer) from table1
|
It's ok now, thanks a lot.
|