Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v6.0
  HXTT Cobol v3.0
  HXTT DBF v6.0
  Buy Now
  HXTT Excel v5.0
  HXTT Paradox v6.0
  HXTT Text(CSV) v6.0
  HXTT XML v2.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
Heng Xing Tian Tai Ltd. of Beijing City (abbr, HXTT)

Count distinct
Fernando Hartmann
2008-10-07 12:47:53.0
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.
Re:Count distinct
HXTT Support
2008-10-08 23:39:06.0
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
Re:Re:Count distinct
Fernando Hartmann
2008-10-09 08:05:19.0
It's ok now, thanks a lot.

Search Key   Search by Last 50 Questions


Copyright © 1999-2017 Heng Xing Tian Tai Ltd. of Beijing City. | All Rights Reserved. | Privacy | Legal | Sitemap