Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct count query

Status
Not open for further replies.

oyam

Programmer
Jan 17, 2001
9
US
I am using Access to query FoxPro database. I am trying to have multiple distinct counts. The query works with one distinct count but not with multiples. Here is the query, any ideas?

Osher

SELECT trnsdate, count(distinct(ordernbr)) as ord_count, count(distinct(ticketnbr)) as employee, count(distinct(tranhst.partnbr)) as TotLines, sum(shipqty) as TotQty, sum(shipqty*itemas.weight) as Totweight
FROM tranhst, salhst, itemas
WHERE trnsdate Between DateTime(2002,04,30) And DateTime(2002,04,30) And transcode = 'SHP' and tranhst.document = salhst.invoicenbr and tranhst.partnbr = salhst.partnbr and salhst.partnbr = itemas.partnum
GROUP BY trnsdate
 
Osher,
Are you doing this query with Access? or are you using SQL Passthrough so ODBC / VFP is doing the query?

In VFP unless 'trnsdate' is exactly '04/30/2002 12:00:00 AM' your Between qualifier won't select any records.

Rick
 
I'm not totally sure how Access ticks, but with a Fox 2.x or VFP SELECT command, you can only use DISTINCT one time as it will give distinct values from the result of the rest of the query.

Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top