Solved

Query details from query results?

Posted on 2011-02-10
4
269 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

773 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