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

Help with tricky query?

Or at least I find it tricky. :-)

Assume we have three tables A, B and C. Table A contains a path and the
distance for traveling that path:

A (PathId, NodeId, Dist (from previous node))
1, 1, 0
1, 2, 10
1, 3, 5

Table B contains observed data on path level:

B (ObsId, PathId)
1, 1
2, 1

Table C contains observed data on node level (~12M rows):

C (ObsId, NodeId, Time (from previous node))
1, 1, 0
1, 3, 10
2, 1, 0
2, 3, 1

What should be observed here is that only nodes where the traveler
stopped are observed i.e. the time for node 3 here is the time for
traveling from node 1.

What I would like to do is to filter out absurd observations in table B
using the travel speed as condition. Something like:

SELECT B.ObsId
FROM JOIN...
WHERE DIST / C.Time < SPEED_LIMIT

The problem is to find out DIST. For me being a tired (for the moment)
and rather inexperienced db programmer this seems a little bit tricky
to solve but hopefully you guys and girls out there disagree.

Oct 24 '06 #1
1 1474
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just a shot in the dark....

PARAMETERS speed_limit INTEGER;
SELECT B.ObsID
FROM (A INNER JOIN B ON A.PathID = B.PathID) INNER JOIN C ON A.NodeID =
C.NodeID AND B.ObsID = C.ObsID
WHERE C.[Time] <0
AND A.Dist / C.[Time] < speed_limit
ORDER BY B.ObsID DESC

Make sure you have indexes on NodeID and ObsID columns in the C table
(for speed) [in the other tables, as well, if they have a large number
of rows].
--
MGFoster:::mgf00 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRUBH8IechKqOuFEgEQLNEgCfZT8uYfpHPKkoBkqpPL2MVF TTOfIAn1xF
aXwnLbx4i0IoTlkhAx2HV0i7
=43md
-----END PGP SIGNATURE-----
Mo*********@gmail.com wrote:
Or at least I find it tricky. :-)

Assume we have three tables A, B and C. Table A contains a path and the
distance for traveling that path:

A (PathId, NodeId, Dist (from previous node))
1, 1, 0
1, 2, 10
1, 3, 5

Table B contains observed data on path level:

B (ObsId, PathId)
1, 1
2, 1

Table C contains observed data on node level (~12M rows):

C (ObsId, NodeId, Time (from previous node))
1, 1, 0
1, 3, 10
2, 1, 0
2, 3, 1

What should be observed here is that only nodes where the traveler
stopped are observed i.e. the time for node 3 here is the time for
traveling from node 1.

What I would like to do is to filter out absurd observations in table B
using the travel speed as condition. Something like:

SELECT B.ObsId
FROM JOIN...
WHERE DIST / C.Time < SPEED_LIMIT

The problem is to find out DIST. For me being a tired (for the moment)
and rather inexperienced db programmer this seems a little bit tricky
to solve but hopefully you guys and girls out there disagree.
Oct 26 '06 #2

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

Similar topics

3
by: cooldv | last post by:
i am running a website on Windows 2000 server with ASP 3 webpages and Access 2000 database. (with a hosting company) traffic is slow at this time but expect to grow. lately i have been reading...
4
by: Angel Cat | last post by:
I have 2 tables joined together by the IDs, People and the pets they own PEOPLE ID NAME 1 JohnSMith 2 JaneDoe PETS ID PET
1
by: Hought, Todd | last post by:
Hi all, trying to run a query against a table, to pull the date out, and order it. problem is, the date is stored in character (string) format, not as an actual timestamp, so parsing it back into...
1
by: PST | last post by:
Here's a problem I'm trying to deal with: I'm working on a Frontpage 2000 website for a boat handicapping system, built in Access 97. What I'm trying to accomplish is: The user enters a...
1
by: Pea | last post by:
I'm working with a system usage database. I want to filter out repetitive logins. The query I have retrieves data like this: USER_DATE USER_TIME1 USER_USERID USER_ACCOUNT...
14
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ;...
6
by: pointBoarder | last post by:
Thanks in advance to all who read this. I've got 3 tables which were created from a txt file dumped from some old system. Header ID -- autonumber, primary OrderNum -- field I want Line
5
by: Johnny Ljunggren | last post by:
Hello all I've got this tricky situation that I would like to solve in SQL, but don't know how to do. This is the table: Id = 3, VId = 2, Time1 = 10:00, Time2 = 14:00 Id = 4, VId = 2, Time1 =...
15
by: edouard.spooner | last post by:
Hi, I have a tricky SQL query problem that I'm having probs with. I have a table which resembles something like this Date | Price1 | Price2 | Price3 01 Jan 2006 | 100 | 100 | 100 02 Jan...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.