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

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -