Solved

Query details from query results?

Posted on 2011-02-10
4
252 Views
Last Modified: 2012-05-11
I need to get some result details based on a seperate query result.

I have two tables, Order and OrderDetails.

I need to pick out all the orders in Orders that were ordered by the same Cust# on the same OrderDate. Sum  (Orders > 1) .

Using those specific order numbers I need to pull out the orderdetails description.

I know this is a little vague but I think it describes the basic need. The results of one query will determine what is pulled by the second query.

Thanks
0
Comment
Question by:LanBuddha
  • 2
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
post sample data or better upload a copy of the db..
0
 
LVL 2

Author Comment

by:LanBuddha
Comment Utility

Order#     OrderDate#      Cust#
123           1/1/2011          1
124           1/1/2011          1
125           1/2/2011          3
126           1/3/2011          4

I should pull back order 123 and 124 because they were placed on same day by same customer.

OrderDetails
Order#      Desc
123          Product1
123          Product2
124          Product3
125          Product1

I need the details of order# 123 and 124 based on previous table.

Thanks
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
test this query


SELECT Order.OrderDate, Order.CustNo, Order.OrderNo,OrderDetails.Desc
FROM [Order] Inner Join [OrderDetails]
ON [Order].OrderNo=[OrderDetails].OrderNo
WHERE (((Order.OrderDate) In (SELECT [OrderDate] FROM [Order] As Tmp GROUP BY [OrderDate],[CustNo] HAVING Count(*)>1  And [CustNo] = [Order].[CustNo])))
ORDER BY Order.OrderDate, Order.CustNo;
0
 
LVL 2

Author Closing Comment

by:LanBuddha
Comment Utility
Great. Got me where I need to be. Nice, quick response.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now