Solved

Query details from query results?

Posted on 2011-02-10
4
261 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
ID: 34866974
post sample data or better upload a copy of the db..
0
 
LVL 2

Author Comment

by:LanBuddha
ID: 34867064

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
ID: 34867149
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
ID: 34867701
Great. Got me where I need to be. Nice, quick response.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Viewers will learn how the fundamental information of how to create a table.

932 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

9 Experts available now in Live!

Get 1:1 Help Now