1
select * from Table1
where Condition 1
union 
select select * from Table1
where Condition 2

RESULTS:

NAME    AMOUNT    TYPE   
ABC      --       Account
ABC      200        --

but i need the results in one row like

NAME     AMOUNT     TYPE
ABC       200       ACCOUNT

How to do in PG?

Riyan
  • 117
  • 1
  • 7

2 Answers2

0

Base on your sample data, this may work

SELECT name,
       MAX(amount) amount,
       MAX(type) type
  FROM table1
 WHERE condition 1
    OR condition 2
 GROUP BY name
Ferdinand Gaspar
  • 2,043
  • 1
  • 8
  • 17
0

I've achieved something like that with the following:

select TABLE_1.DESCRIPTION_COLUMN,

(array(select TABLE_2.INFO_COLUMN from TABLE_2 where TABLE_1.ID = TABLE_2.ID_TABLE_1))[1],
(array(select TABLE_2.INFO_COLUMN from TABLE_2 where TABLE_1.ID = TABLE_2.ID_TABLE_1))[2]

from TABLE_1


WHERE TABLE_1 = 1

Source/Help:

https://stackoverflow.com/a/6402163/1856745