| Alejandro Mesa 2005-07-22, 9:23 am |
| Try,
select
crashid,
case t2.c1
when 1 then veh1_type
when 2 then veh2_type
when 3 then veh3_type
end as veh_type,
t2.c1 as veh_number
from
t1
cross join
(
select cast(1 as int) as c1
union all
select cast(2 as int) as c1
union all
select cast(3 as int) as c1
) as t2
go
AMB
"meyvn77@yahoo.com" wrote:
>
> I have a flat file table that describes crash data in SQL Server.
> It contains vehicle information.
>
> I would like to know if anyone knows a SQL statement that could go from
> this
> table= events
>
> CRASHID | VEH1_TYPE | VEH2_TYPE | VEH_3TYPE
> -------------------------------------------
> 555555 | CAR | TRUCK | VAN
>
> TO
>
> CRASHID | VEH_TYPE | VEH_NUMBER
> --------------------------------
> 555555 CAR 1
> 555555 Truck 2
> 555555 VAN 3
>
>
> Any Ideas? I am relitively new at this and can only see how it could be
> done by creating multiple tables and appending them.
> Any help that could create the end selection in one query would be
> great.
>
> Thanks,
> Chuck
>
>
|