Take a look at
Dynamic Crosstab Queries at
http://www.sqlmag.com/Articles/Index.cfm?ArticleID=15608>Hi every body, Is it possible to merge two tables in one with only one SELECT-SQL? The first table is the parent and the second is the children. I want the select SQL return me the result on one row per parent!!!
>
>Example:
>table constructors (parent) table drivers (children)
>NAME_CONST (fields) NAME_CONST, NAME_DRIVER
>---------- ---------- -----------
>Ferrari Ferrari Michael Schumacher
>Williams Ferrari Rubbens Barrichello
>Bar Williams Ralph Schumacher
>Renault Williams Juan Pablo Montoya
> Bar Jacques Villeneuve
>
>The number of childrens can be different for each parent, i don't know the maximum of childrens, and the minimun can be zero!!!
>
>I would like the result of the SQL select seem like that:
>NAME_CONST NAME_DRIVER1 NAME_DRIVER2
>---------- ------------ ------------
>Bar Jacques Villeneuve (NULL)
>Ferrari Michael Schumacher Rubben Barrichello
>Renault (NULL) (NULL)
>Williams Ralph Schumacher Juan Pablo Montoya
>
>I works with Sql Server 2000!!!
>
>Thanks!!!
--sb--