Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Can tables be joined and selectively filtered?

Author  Topic 

martyn11post
Starting Member

2 Posts

Posted - 2011-08-02 : 16:40:12
Is it possible to create a query which joins several tables of data and select specific data?

This is for a manufacturing process where there are three tables. For simplicity I will call then table1, table2, & table3

table1 has several columns: entry_id, customer, weight, type ...etc
From this table I need, entry_id & customer.

table2 has entry_id, exit_id, process. I need entry&exit id to link table1 to table3 (process is time, this is not needed)

Finally table 3 (this is where I have the problem) has column name exit_id number parameter value distance time

each exit_id has several parameters (temp1, temp2) for each parameter there can be n number of readings, these are measured by number (1,2,3 etc) and distance (e.g 300m, 277m, 222m etc ..for unknown reason this is measured in reverse) Time is just a normal timestamp for each reading.

The parameters measure when there is a process change (sudden temp rise etc) Therefore there could be 2 readings or 50+ per exit_id.

I only need the final reading, because of a silly glitch this is the highest distance or number to give the process parameter at the point the lab tests the product.

so for one exit_id I need temp1 at 450m (highest number)
The next might be for the temp1 at 392m (highest number for that product)

Any suggestions? Is this possible?!

Thanks,
martyn

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-03 : 01:04:10
its possible. see scenario 2 here

http://visakhm.blogspot.com/2010/01/multipurpose-apply-operator.html


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

martyn11post
Starting Member

2 Posts

Posted - 2011-08-04 : 18:09:21
Thanks for the suggestion, although we are using 2000, therefore I assume it is not possible!
Go to Top of Page
   

- Advertisement -