# Miscellaneous > Structured Query Language (SQL) >  sql query

## evetsarual

Hello, I have this table in Microsoft SQL.

table

    ref           Type        Description

    aaa             1          rossi mario
    aaa             2          via Verdi 1
    aaa             3          20124 Milano
    bbb             1          bianchi nicola
    bbb             2          via Roma 4
    bbb             3          20100 Milano

I need to use data in office compilation, so i wish to obtain an excel sheet with a sql query structured in this way:


ref         Description 1      Description 2         Description 3

aaa           rossi mario        via Verdi 1            20124 Milano

bbb          bianchi nicola     via Roma 4            20100 Milano

How may I obtain this ?

Thanks

Stefano

----------


## rmiao

Which version of sql server you have? Take look at pivot operator in books online if you have sql2k5 or up.

----------

