473,407 Members | 2,676 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,407 software developers and data experts.

Subquery looking for missing information

The DB in question contains daily stock transactions keyed by ticker
(symbol) and date.

Unfortunately all dates do not exist for all ticker symbols.

To assist the process, there are two temporary tables: Tickers (the
collection of all tickers) AND TransactionDates (the collection of all
dates)

The latest failed attempt at finding the missing transaction dates by
ticker is

SELECT Dailys.Ticker, TransactionDates.Date
FROM Tickers INNER JOIN (TransactionDates INNER JOIN Dailys ON
TransactionDates.Date = Dailys.Date) ON Tickers.Ticker = Dailys.Ticker
WHERE (((TransactionDates.Date)=(SELECT TransactionDates.Date FROM
TransactionDates LEFT JOIN Dailys ON TransactionDates.Date =
Dailys.Date WHERE (((Dailys.Date) Is Null)))))
ORDER BY Dailys.Ticker, TransactionDates.Date;

This returns no hits when there are missing transaction dates (April
19th is missing in all cases, there are others).

Any insights into this issue will be appreciated.
Nov 12 '05 #1
2 1596
"Frank" <to*****@fctvplus.net> wrote in message
news:f0**************************@posting.google.c om...
The DB in question contains daily stock transactions keyed by ticker
(symbol) and date.

Unfortunately all dates do not exist for all ticker symbols.

To assist the process, there are two temporary tables: Tickers (the
collection of all tickers) AND TransactionDates (the collection of all
dates)

The latest failed attempt at finding the missing transaction dates by
ticker is

SELECT Dailys.Ticker, TransactionDates.Date
FROM Tickers INNER JOIN (TransactionDates INNER JOIN Dailys ON
TransactionDates.Date = Dailys.Date) ON Tickers.Ticker = Dailys.Ticker
WHERE (((TransactionDates.Date)=(SELECT TransactionDates.Date FROM
TransactionDates LEFT JOIN Dailys ON TransactionDates.Date =
Dailys.Date WHERE (((Dailys.Date) Is Null)))))
ORDER BY Dailys.Ticker, TransactionDates.Date;

This returns no hits when there are missing transaction dates (April
19th is missing in all cases, there are others).

i think this will work

---------------------------------------
select t.Ticker, d.[Date]
from Tickers as t, TransactionDates as d
where not exists
(
select * from Dailys as y
where y.[Date] = d.[Date]
and y.Ticker = t.Ticker
)
order by t.Ticker, d.[Date]
--------------------------------------

I don't know what performace will be like - in sql server this would
probably be fine but in access your mileage may vary.

BTW, I wouldn't use "Date" for a column name - it's a reserved word.





Nov 12 '05 #2
"John Winterbottom" <as******@hotmail.com> wrote in message news:<2g************@uni-berlin.de>...
"Frank" <to*****@fctvplus.net> wrote in message
news:f0**************************@posting.google.c om...
The DB in question contains daily stock transactions keyed by ticker
(symbol) and date.

Unfortunately all dates do not exist for all ticker symbols.

To assist the process, there are two temporary tables: Tickers (the
collection of all tickers) AND TransactionDates (the collection of all
dates)

The latest failed attempt at finding the missing transaction dates by
ticker is

SELECT Dailys.Ticker, TransactionDates.Date
FROM Tickers INNER JOIN (TransactionDates INNER JOIN Dailys ON
TransactionDates.Date = Dailys.Date) ON Tickers.Ticker = Dailys.Ticker
WHERE (((TransactionDates.Date)=(SELECT TransactionDates.Date FROM
TransactionDates LEFT JOIN Dailys ON TransactionDates.Date =
Dailys.Date WHERE (((Dailys.Date) Is Null)))))
ORDER BY Dailys.Ticker, TransactionDates.Date;

This returns no hits when there are missing transaction dates (April
19th is missing in all cases, there are others).

i think this will work

---------------------------------------
select t.Ticker, d.[Date]
from Tickers as t, TransactionDates as d
where not exists
(
select * from Dailys as y
where y.[Date] = d.[Date]
and y.Ticker = t.Ticker
)
order by t.Ticker, d.[Date]
--------------------------------------

I don't know what performace will be like - in sql server this would
probably be fine but in access your mileage may vary.

BTW, I wouldn't use "Date" for a column name - it's a reserved word.


Thanks a lot -- It works but slowly. The Daily table is now over
110,000 rows. As it is a maintenance function and not directly tied to
User response, I'll live with it for a while. I suspect I'll move the
whole thing to MySQL. The ultimate User is a university.

Thanks for the heads up on the Key Word. Using Access as a prototype
tool does lead to sloppy habits.

Again thanks.
Nov 12 '05 #3

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

Similar topics

2
by: Greg Stark | last post by:
I find I often want to be able to do joins against views where the view are aggregates on a column that has an index. Ie, something like SELECT a.*, v.n FROM a JOIN (select a_id,count(*) as n...
2
by: btober | last post by:
I run the following script to export some data from my development database and then update or insert the records into to the quality assurance testing database, but I get a warning notice that I...
2
by: edself | last post by:
Greetings, I am semi-new to Access and have a query question. I presume the solution is easy, but need some help. I have created a database with a Contact table. The contact table contains...
8
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...
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
1
by: mark | last post by:
I've got a report whose recordsource is a query: SELECT .Company, qryGatherCreditCardInfoFromCallRecords.* FROM qryGatherCreditCardInfoFromCallRecords LEFT JOIN ( LEFT JOIN ON .=.) ON...
1
by: Tim Marshall | last post by:
A2003. I am getting this error message when I try to set a report's recordsource to an SQL statement or a saved querydef that uses sub-queries. I've debug.printed the SQL, and run it as a stand...
13
by: ThePrinceIsRight | last post by:
I have a problem with using a subquery in MS Access. The purpose of the sub-query is to create a list of people who have had doctor exams in the past 6 months and exclude them from the main query....
1
by: avsesis | last post by:
Hi - I have spent all morning surfing this problem and cannot find a match that might help so am asking for help. I want to fill a dataset with information about orders placed for a particular type...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
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,...
0
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...

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.