Combine records in one row with SQL -
how combine 2 records 1 row in sql query? data looks this:
name | address | address_type -------------------------------------- smith | 123 main st | p smith | po box 123 | m
i need result looks this:
name | p_address | m_address --------------------------------------- smith | 123 main st | po box 123
use conditional aggregate
this
select name, max(case when address_type = 'p' address end) p_address, max(case when address_type = 'm' address end) m_address yourtable group name
Comments
Post a Comment