473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Distinct count syntax?

In the first line I'm trying to count the the unqiue values of the ID
column, but I'm getting syntax error, any idea how to format the distinct
count?

SELECT Count(test.ID) AS IDCOUNT FROM (select distinct test.ID FROM test),
Sum(test.balance) AS BAL, test.statement, billing.YYMM
FROM billing INNER JOIN test ON billing.ID = test.ID
WHERE (((test.invoice) Like "X*") AND ((test.due)=0) AND
((test.collections)=0))
GROUP BY test.statement, billing.YYMM;
Nov 12 '05 #1
2 10518
Unfortunately, count distinct is simply not provided in Jet. You have to make
a nested query instead, where the first query groups by all the intended group
by fields plus the value in question, then the second includes just the
intended group by fields and includes a simple Count(*) in the Select list.

On Sat, 24 Jan 2004 10:24:22 +0100, "Anne Heddal" <an********@yahoo.com>
wrote:
In the first line I'm trying to count the the unqiue values of the ID
column, but I'm getting syntax error, any idea how to format the distinct
count?

SELECT Count(test.ID) AS IDCOUNT FROM (select distinct test.ID FROM test),
Sum(test.balance) AS BAL, test.statement, billing.YYMM
FROM billing INNER JOIN test ON billing.ID = test.ID
WHERE (((test.invoice) Like "X*") AND ((test.due)=0) AND
((test.collections)=0))
GROUP BY test.statement, billing.YYMM;


Nov 12 '05 #2
Thought I tried that in the syntax below, but I guess my nesting is wrongly
formatted...

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:lj********************************@4ax.com...
Unfortunately, count distinct is simply not provided in Jet. You have to make a nested query instead, where the first query groups by all the intended group by fields plus the value in question, then the second includes just the
intended group by fields and includes a simple Count(*) in the Select list.
On Sat, 24 Jan 2004 10:24:22 +0100, "Anne Heddal" <an********@yahoo.com>
wrote:
In the first line I'm trying to count the the unqiue values of the ID
column, but I'm getting syntax error, any idea how to format the distinct
count?

SELECT Count(test.ID) AS IDCOUNT FROM (select distinct test.ID FROM test),Sum(test.balance) AS BAL, test.statement, billing.YYMM
FROM billing INNER JOIN test ON billing.ID = test.ID
WHERE (((test.invoice) Like "X*") AND ((test.due)=0) AND
((test.collections)=0))
GROUP BY test.statement, billing.YYMM;

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dean | last post by:
I want to build query to return how many rows are in this query: select distinct c1, c2 from t1 But SQL won't accept this syntax: select count (distinct c1, c2) from t1 Does someone know how...
5
by: Chris Kettenbach | last post by:
Good Morning, Sorry for xposting. Just need a liitle help. I have an xml file that's generated from a database. How do I select distinct values from a field in xslt and then loop through the...
17
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched...
1
by: nfrodsham | last post by:
In Microsoft's help literature, it states: "You can filter out non-unique rows by using the DISTINCT option of an aggregate function" I am trying to do this in Access 2003 with the COUNT...
7
by: Johnathan Doe | last post by:
I can google search to find the range of values that can be represented in a float by reading up on the IEEE std, but is that the same as how many distinct values that can go in a float type? ...
2
by: Michael Howes | last post by:
I have a single DataTable in a DataSet. It has 4 columns and i'd like to get a handful of counts of unique items in 3 of the 4 columns. Can a DataTables Select or Compute methods to COUNT DISTINCT?...
1
by: Bill | last post by:
I'm trying to write a query that will select a distinct count of more than one field. I have records that display user productivity. Each of the records have a time associated with it and I want to...
4
by: tom booster | last post by:
Hi All, I'm trying to convert a T-SQl query to DB2. I have two tables policy and policyHolder. I would like a count of the amount of distinct poicyHolders per policy, for a particular set of...
1
by: NoviceDBLearner | last post by:
I need to be able to get rid of the duplicate artists before I count them due to the fact that I will get duplicates in the SQL result window which I don't want. What do I write in order to make this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.