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?

1
  • 2
    What you want is a JOIN not a UNION Commented Aug 29, 2017 at 17:53

2 Answers 2

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 
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.