473,625 Members | 2,853 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Count number of orders and number of different itemnumbers

Hi

I have got a table with some sales transactions. It has got 3 fields
1) Ordernumber
2) Item number
3) Shippingdate

Now I want to make ONE (not two) query that shows how many different orders
quarterly, and at the same time how many different item numbers used in each
quarter.

Each record has a different ordernumber, so it is just to count the lines
and grouped by each quarterly, to find the number of orders, But my problem
is, how do I count the number of differt itemnumbers at the same time. In
other words I want to become the following result in one querry:

Quarter: # Orders: #Items
1 200 15
2 130 24
3 etc. etc.
4

Thanks in advance
Henry

Nov 12 '05 #1
3 5091
Use a Summation query grouped on Quarter, count Orders and Items.

"Anne" <av*@telmore.ru > wrote in message
news:3f******** *************** @dread16.news.t ele.dk...
Hi

I have got a table with some sales transactions. It has got 3 fields
1) Ordernumber
2) Item number
3) Shippingdate

Now I want to make ONE (not two) query that shows how many different orders quarterly, and at the same time how many different item numbers used in each quarter.

Each record has a different ordernumber, so it is just to count the lines
and grouped by each quarterly, to find the number of orders, But my problem is, how do I count the number of differt itemnumbers at the same time. In
other words I want to become the following result in one querry:

Quarter: # Orders: #Items
1 200 15
2 130 24
3 etc. etc.
4

Thanks in advance
Henry

Nov 12 '05 #2
Hi Ron

I'am not realy sure I understand.

An example:
I got theese 3 records:
[Date] [Ordernumber] [Itemnumber]

20031104 1234 12
20031104 4567 12
20031104 8910 9

Runing the query I want the following result:

Quarter # of orders # of different items
4 3 2

Best regards
Henry

"paii, Ron" <pa**@packairin c.com> skrev i en meddelelse
news:vq******** ****@corp.super news.com...
Use a Summation query grouped on Quarter, count Orders and Items.

"Anne" <av*@telmore.ru > wrote in message
news:3f******** *************** @dread16.news.t ele.dk...
Hi

I have got a table with some sales transactions. It has got 3 fields
1) Ordernumber
2) Item number
3) Shippingdate

Now I want to make ONE (not two) query that shows how many different

orders
quarterly, and at the same time how many different item numbers used in

each
quarter.

Each record has a different ordernumber, so it is just to count the lines and grouped by each quarterly, to find the number of orders, But my

problem
is, how do I count the number of differt itemnumbers at the same time. In other words I want to become the following result in one querry:

Quarter: # Orders: #Items
1 200 15
2 130 24
3 etc. etc.
4

Thanks in advance
Henry



Nov 12 '05 #3
assuming your table is called 'tblSales'

create a query "qryOrdersByDat e"
SELECT tblSales.shippi ngDate, Count(*) AS orderCount
FROM tblSales
GROUP BY tblSales.shippi ngDate;

create a second query "qryUniqueItems "
SELECT DISTINCT tblsales.shippi ngDate, tblsales.itemNu mber
FROM tblsales;

the final query "qrySales" will give you what you need
SELECT tbl1.shippingDa te
, (select orderCount from qryOrdersByDate as tbl2 where
tbl1.shippingDa te=tbl2.shippin gDate) as orderCount
, (select count(itemNumbe r) from qryUniqueItems as tbl3
where tbl1.shippingDa te=tbl3.shippin gDate) as itemCount
FROM tblSales as tbl1
GROUP BY tbl1.shippingDa te;
"Anne" <av*@telmore.ru > wrote in message news:<3f******* *************** *@dread16.news. tele.dk>...
Hi Ron

I'am not realy sure I understand.

An example:
I got theese 3 records:
[Date] [Ordernumber] [Itemnumber]

20031104 1234 12
20031104 4567 12
20031104 8910 9

Runing the query I want the following result:

Quarter # of orders # of different items
4 3 2

Best regards
Henry

"paii, Ron" <pa**@packairin c.com> skrev i en meddelelse
news:vq******** ****@corp.super news.com...
Use a Summation query grouped on Quarter, count Orders and Items.

"Anne" <av*@telmore.ru > wrote in message
news:3f******** *************** @dread16.news.t ele.dk...
Hi

I have got a table with some sales transactions. It has got 3 fields
1) Ordernumber
2) Item number
3) Shippingdate

Now I want to make ONE (not two) query that shows how many different orders quarterly, and at the same time how many different item numbers used in each quarter.

Each record has a different ordernumber, so it is just to count the lines and grouped by each quarterly, to find the number of orders, But my problem is, how do I count the number of differt itemnumbers at the same time. In other words I want to become the following result in one querry:

Quarter: # Orders: #Items
1 200 15
2 130 24
3 etc. etc.
4

Thanks in advance
Henry


Nov 12 '05 #4

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

Similar topics

3
108613
by: Prem | last post by:
To all gurus, I am developing an application in which i want to show the number of rows returned by the query. e.g. Select Categories.CategoryName, Products.ProductName, Sum((.UnitPrice**(1-)/100)*100) AS ProductSales FROM ((( INNER JOIN Orders ON .OrderID = Orders.OrderID)
5
44333
by: Mike Bannon | last post by:
Hi All We have an order processing database which includes the standard Order Header/Order Lines tables. I'm trying to write a query to get the average number of lines per order over a given period, and I'm stuck :-( I can get the number of lines per order with: SELECT COUNT(*) FROM OrderDetails INNER JOIN Order Header ON
2
6721
by: PaulMac | last post by:
This seems so easy....change the join to show all records, but the zero records still do not show I want to join 2 tables....basically Customers and Orders....get the total number of orders for each Customer within a date range...but I can't seem to show records where the total for a particular Customer is zero (which is very important info) There must be an easy way???
2
4266
by: Paula | last post by:
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...
10
6716
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that contains only tables. I have linked the tables for the front end to the back end database. I am trying to set the recordsource of a form to a query established by the user to narrow the scope but I don't want to display the form if there are no...
15
1777
by: Hexman | last post by:
Hello All, How do I limit the number of detail records selected in a Master-Detail set using SQL? I want to select all master records for a date, but only the first 3 records for the details (based on the primary key of the detail record). I've been trying with "TOP 3", but can't get anywhere. Using Access 2000. Something like: SELECT t1.*, TOP 3 t2.*
2
3723
by: rn5a | last post by:
A SQL Server 2005 stored procedure expects a parameter 'UserID' depending upon which it retrieves the no. of records & OrderIDs corresponding to the 'UserID' from a DB table (note that OrderID & UserID are two of the columns in the DB table). So for e.g. consider a user whose UserID=6 & the DB table has 3 records whose UserID=6. In other words, there are 3 OrderID records of the user whose UserID=6, say, OrderID=8, OrderID=17 & OrderID=29....
5
18106
by: whitsey | last post by:
Here is what I have: SELECT (SELECT COUNT(*) AS SEARCHES FROM SEARCHES INNER JOIN GROUPS ON SEARCHES.SITE_ID = GROUPS.SITE_ID WHERE
5
4825
by: Nasher | last post by:
How do you create a field on a form that counts the selected records, only if a certain word is in the field. Records are selected via a combo box on a form header. I then have tabs below that display different subforms.(One of the tabs is orders) Basically i have combo box on the orders form that lists all posible locations for a particular item e.g. "location 1 - sub location 1" "location 1 - sub location 2" "location 2 - sub...
0
8692
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, 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...
0
8635
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 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...
1
8354
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,...
0
7182
agi2029
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...
1
6116
isladogs
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...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.