Skip to content
Advertisement

Transposing Column Data into Row Data SQL

I have some data that looks like this in an SQL table.

The issue i have, i need to create 2 records from this data (all information from 1 and all information of 2). Example below.

Does anyone have an ideas how to do so?

Thanks

Advertisement

Answer

A standard (ie cross-RDBMS) solution for this is to use union:

Depending on your RBDMS, neater solutions might be available.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement