SQLTeam.com | Weblogs | Forums

X and Y data from 2 table queries


Query1 returns a table (indep ) with values as the X value for plot
Query 2 returns a table ( depend ) with values for Y values of the plot

I'd like to do a select to inner join indep and with depend on certain criteria in order to end up with the
XValue on same row as YValue in order to plot.

Suggestions ?


Can you supply table definitions, sample input/output?


I think this would model what I need to do

declare @indep table (
RunID int ,
Xname varchar(10),
Xvalue int
insert into @indep (RunID,Xname,Xvalue)
(1, 'Sensor1',10),
(2,'Sensor1', 7);

declare @depend table (
RunID int ,
Yname varchar(10),
Yvalue int
insert into @depend (RunID,Yname,Yvalue)
(1, 'Sensor2',5),
(2,'Sensor2', 3);

with an output as
RunId Xname XValue YName YValue
1 Sensor1 10 Sensor2 5
2 Sensor1 7 sensor 2 3



SELECT I.RunID, I.Xname, I.Xvalue, D.Yname, D.Yvalue
FROM @indep I 
INNER JOIN @depend D ON I.RunID = D.RunID;


Works great thanks !


Glad I could help.