A query contains the fields CustomerID, CustomerName, OrderID, OrderDate and
ItemID.
The query is based on a customers table, orders table, and order details
table. The orders table has a foreign key of CustomerID and is joined to
CustomerID in the customer table. The order details table has a foreign key
of OrderID and is joined to OrderID in the orders table. The number of
records in the query is determined by the total number of items in all the
orders. Of course, each record in the query contains OrderID. When I convert
the query to a totals query and do a Count on the OrderID field by Customer
and Year of OrderDate, the number I get is the same as the number of items
because each record in the query contains OrderID. How can I do a count so
that where there are duplicate OrderIDs, that OrderID is only counted once?
Is there a CountDistinct, DistinctCount or some such?
Thanks!
Paula 2 4267
Paula,
I don't believe there's a
count distinct
but there is a
select distinct.
So I'd suggest a query with
select distinct OrderID etc. etc.
and then base your count query on the select distinct query.
HTH -Linda
"Paula" <pm*****@notmym ail.com> wrote in message
news:vD******** *********@newsr ead2.news.atl.e arthlink.net... A query contains the fields CustomerID, CustomerName, OrderID, OrderDate
and ItemID. The query is based on a customers table, orders table, and order details table. The orders table has a foreign key of CustomerID and is joined to CustomerID in the customer table. The order details table has a foreign
key of OrderID and is joined to OrderID in the orders table. The number of records in the query is determined by the total number of items in all the orders. Of course, each record in the query contains OrderID. When I
convert the query to a totals query and do a Count on the OrderID field by
Customer and Year of OrderDate, the number I get is the same as the number of items because each record in the query contains OrderID. How can I do a count so that where there are duplicate OrderIDs, that OrderID is only counted
once? Is there a CountDistinct, DistinctCount or some such?
Thanks!
Paula
Use SELECT DISTINCT instead of just SELECT. There's no doubt an
option for it in the query builder, but just click the SQL button in
design view and type it yourself. Then you should only get unique
values. Of course, if you have fields in your query that make your
records unique, then this won't work. Assuming it does, you could
then base your totals query on this query. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Drew |
last post by:
I have a permission tracking app that I am working on, and I have made the
insert page for it. I am having issues on how to prevent duplicates from
getting entered.
Currently the interface for the app has a mixture of select boxes, list
boxes and checkboxes. The form submits the page to processAIMR.asp and then
does the inserting. I am using a loop to insert a new record for each
checkbox checked or listbox entry selected.
My...
|
by: Jerry |
last post by:
Say a table has four fields:
ID (PK)
Field1
Field2
Field3
Field 1 is indexed as Yes(No Duplicates)
When a duplicate is entered in Field1, nothing happens until you try to save
the record then this error message appears:
"The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key or
|
by: vsgdp |
last post by:
I have a container of pointers. It is possible for two pointers to point to
the same element. I want to remove duplicates.
I am open to which container is best for this.
I thought of using std::set, but my elements do not have a '<' operator, as
it does not make sense. I could add an integer index to the data structure
so that each element has a unique index associated with it and then override
'<' to sort by index, but I am not...
|
by: AtCor |
last post by:
Site Patient Visit
Number Number Number
1 1 1
1 1 2
1 2 1
1 3 1
2 1 1
2 2 1
3 1 1
3 1 2
|
by: yin_n_yang74 |
last post by:
I am new to SQL and SQL Server world. There must be a simple solution
to this, but I'm not seeing it. I am trying to create a crystal
report (v8.5) using a stored procedure from SQL Server (v2000) in
order to report from two databases and to enable parameters.
When I create the stored procedure, it joins multiple one-to-many
relationship tables. This results in repeated/duplicate records. Is
this an issue that should be solved within...
| |
by: AndyB |
last post by:
I have found a lot of material on removing duplicates from a list, but I
am trying to find the most efficient way to just check for the existence
of duplicates in a list. Here is the best I have come up with so far:
CheckList = for x in self.__XRList]
FilteredList = filter((lambda x:x != 0),CheckList)
if len(FilteredList) len(sets.Set(FilteredList)): return
False
The first statement pulls the slice out of a matrix I need to check.
|
by: hanshirley88 |
last post by:
Hi,
I am doing an expense and funding report which contains a list of
consumers by Region and then by SiteID. For example,
Region: NE
Site: NEMV
1. Mary Doe
2. Len Willams
|
by: ryan.paquette |
last post by:
In the table there are 2 fields in which I wish to limit (i.e. No
Duplicates)
Although I do not want to limit them to "No Duplicates" separately.
I need them to be limited to "No Duplicates" as if they were one
field.
The 2 fields are "Employee_Name" & "Training_Course".
*(There is another table for Employees & another for Training Courses,
both of which are related to this table.)
|
by: squalled |
last post by:
I need to find the no. of duplicates in this array. There is something wong in the loop, can anyone please look at it and point me towards right direction.
Thanks
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |