sql - Select data from onw row for One column of report and another row for another coumn based on the type -
i have table called address has next data name | address line 1 | type ronn | 123street1 nc | primary ronn | 123xyz rd nc | office
now, creating study xyz has 2 columns. name, primary address , office address.
i want-
name | primary address | work address ronn | 123street1 nc | 123xyz rd nc
how fetch 1 row 1 column of xyz , row column of xyz?
i tried using decode, homecoming multiple rows, not correct.
i hope making sense..it hard post thing spaces.
i believe best alternative utilize max() , grouping name:
select a.name, max(case when type = 'primary' address_line_1 else null end) primary_address, max(case when type = 'office' address_line_1 else null end) work_address address grouping a.name
sql oracle
No comments:
Post a Comment