473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access SubQuery Help Needed.....................

Don't know if this is the proper newsgroup to post to. Sorry if not.

Can't figure this one out. Using Access 2003. I have 2 tables, IMast
(table of part info) and THist (part transaction history).

I need to select all parts that have a product code = "CAST" and list
the last 10 history transaction if they are within 90 days of the run
date.

From the IMast table I need the columns: part, descr, pcode. From the
THist I need: wonumber, wodate, wocust, ..... I will need a few more
columns from each of the tables for the final report.

I've tried many variations of the Select statement without success.
Such as:

Select part, desc, pcode
from (Select top 10 wonumber, wodate, wocust
from THist
where (pcode = "CAST") and (part=wopart) and ((thisdate -
wodate) < 91)
order by part, wodate, wonumber

Looking for a solution,

Hexman

Jan 8 '06 #1
2 1381
FROM using subquery not a table(s) is not supported in SQL92.

<code lang="SQL" type="AirCode">

SELECT TOP 10 i.part, i.descr, i.pcode, p.wonumber, p.wodate, p.wocust
FROM IMast i INNER JOIN THist p ON i.part = p.wopart
WHERE i.pcode = "CAST"
AND ((thisdate - wodate) < 91)

</code>

Regards John

"Hexman" <He****@binary.com> wrote in message
news:48********************************@4ax.com...
Don't know if this is the proper newsgroup to post to. Sorry if not.

Can't figure this one out. Using Access 2003. I have 2 tables, IMast
(table of part info) and THist (part transaction history).

I need to select all parts that have a product code = "CAST" and list
the last 10 history transaction if they are within 90 days of the run
date.

From the IMast table I need the columns: part, descr, pcode. From the
THist I need: wonumber, wodate, wocust, ..... I will need a few more
columns from each of the tables for the final report.

I've tried many variations of the Select statement without success.
Such as:

Select part, desc, pcode
from (Select top 10 wonumber, wodate, wocust
from THist
where (pcode = "CAST") and (part=wopart) and ((thisdate -
wodate) < 91)
order by part, wodate, wonumber

Looking for a solution,

Hexman

Jan 8 '06 #2
John,

An Order By clause is also needed, so the Top 10 will return the appropriate
data.

Kerry Moorman
"John Griffiths" wrote:
FROM using subquery not a table(s) is not supported in SQL92.

<code lang="SQL" type="AirCode">

SELECT TOP 10 i.part, i.descr, i.pcode, p.wonumber, p.wodate, p.wocust
FROM IMast i INNER JOIN THist p ON i.part = p.wopart
WHERE i.pcode = "CAST"
AND ((thisdate - wodate) < 91)

</code>

Regards John

"Hexman" <He****@binary.com> wrote in message
news:48********************************@4ax.com...
Don't know if this is the proper newsgroup to post to. Sorry if not.

Can't figure this one out. Using Access 2003. I have 2 tables, IMast
(table of part info) and THist (part transaction history).

I need to select all parts that have a product code = "CAST" and list
the last 10 history transaction if they are within 90 days of the run
date.

From the IMast table I need the columns: part, descr, pcode. From the
THist I need: wonumber, wodate, wocust, ..... I will need a few more
columns from each of the tables for the final report.

I've tried many variations of the Select statement without success.
Such as:

Select part, desc, pcode
from (Select top 10 wonumber, wodate, wocust
from THist
where (pcode = "CAST") and (part=wopart) and ((thisdate -
wodate) < 91)
order by part, wodate, wonumber

Looking for a solution,

Hexman


Jan 8 '06 #3

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

Similar topics

14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
10
by: Steve Jorgensen | last post by:
Hi all, Over the years, I have had to keep dealing with the same Access restriction - that you can't update a table in a statement that joins it to another non-updateable query or employs a...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
9
by: Warren | last post by:
I am trying to create a report that does the following: Access Data in Query: NAME | DATE | SALE TYPE | ------------------------- John DOE | 1282003 | TYPE A Jane DOE | 1282003 | TYPE C...
9
by: kandiko | last post by:
Hi all, Here is my dilemma. I have two tables, one called HS DATA and one called ImportedHighSchools. Both tables contain an ID code for each record.
9
by: Steve Jorgensen | last post by:
Hi all, Frankly, this is such an off-beat thing, I don't know if anyone else here will ever have the same issue. Just in case anyone does, though... I needed to be able to search for the...
15
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...
1
by: timn | last post by:
Translating Access SQL queries into SQL subqueries. -------------------------------------------------------------------------------- I have a query in Access that uses a subquery, I would like...
1
NeoPa
by: NeoPa | last post by:
Access QueryDefs Mis-save Subquery SQL Access stores its SQL for Subqueries in a strange manner :s It seems to replace the parentheses "()"with square brackets "" and (often) add an extraneous...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.