SQL 2005 Filling NULLS

  • Hello all!

    Im trying to get a query to work (well actually a view) so that i get data from table1 (CUCY_DATA) and join some of the columns from table2 (DIMENSIONS). Whenever i do this i get null values. imagine this: you move a car back and forth. Everytime it has been moved forward and backward it stores certain data. When however certain parameters are changed, for instance the force you push the car with or the maximum speed of the car they are stored in a separate table. Now i want to combine both tables but as you can imagine something like this is produced:

    |_Movement_|_Time_|_Force_|_Max_Speed_|

    | 1 | 3 | 5 | 10 |

    | 2 | 3.1 | NULL | NULL |

    | 3 | 3.0 | NULL | NULL |

    | 4 | 3.1 | NULL | NULL |

    | 5 | 3.2 | NULL | NULL |

    | 6 | 1.5 | 10 | 15 |

    | 7 | 1.6 | NULL | NULL |

    | 8 | 1.4 | NULL | NULL |

    These NULLS are my problem, i want those to be 5, 10 for the first 5 Movements and 10, 15 for the final 3 Movements.

    Can someone help me with this?

    Kind regards, Bob

  • Please provide us with your code and sample data from both tables.

    Just guessing from what you write, you left join table2 to table1 with the _Movement_ ID.

    You will first need to derive the next _Movement_ ID for each row in table2 and then alter your join condition to between _Movement_ ID and next _Movement_ ID -1.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply