Archives of the TeradataForum
Message Posted: Thu, 07 Oct 2010 @ 21:22:57 GMT
I am relatively new to SQL and Teradata and currently faced with a task where I have essentially 2 tables one is a short table(Fault) (200 rows) containing UnitSerNum & EventDate, the other table(Data) contains the various sensor values by timestamp. What I need to do is pull all the data points for each of the UnitSerNum for a period of time before the event date (and each eventDate is unique it is a timestamp as well).
Doing this for 1 unit it would look likeSelect * >From Data as d, Fault as f Where d.UnitSernum = 186345 And f.UnitSernum = d.UnitSernum And d.timestamp <= f.eventdate And d.timestamp >= (f.eventdate 6 months) (not correct format, shown for clarity)
Part of the problem is that, each query will generate a large data file. Is there an easy way to step through the Fault table, using the UnitSerNum & EventDate as variables into a query against the Data table? I don't particularly want to generate 200 separate queries by hand and it seems like there should be a mechanism to have separate output files generated automatically. I hope, I have stated my problem clearly enough. I would appreciate any feedback.
|Copyright 2016 - All Rights Reserved|
|Last Modified: 23 Jun 2019|