Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Query from a union
Thu, Apr 9 2015 11:30 AMPermanent Link

Boss

Hi I'm trying to narrow down my search, I need to group by the GUID and grab the max value from the two queries that were union.

Working union script

Select * from memory\m2 as X
union
select * from memory\m3 as y

my goal is to do something along the lines of this sql statement

select GUID, Max(amount) as Amount from
     (Select * from memory\m2 as X
     union
     select * from memory\m3 as y) as z")
group by GUID

Both X and Y have 2 columns [GUID, Amount]

May I ask how would I selected from the union?
Tue, Apr 14 2015 1:36 PMPermanent Link

Boss

Bump
Wed, Apr 15 2015 5:52 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Boss

<<
Hi I'm trying to narrow down my search, I need to group by the GUID and grab the max value from the two queries that were union.

Working union script

Select * from memory\m2 as X
union
select * from memory\m3 as y

my goal is to do something along the lines of this sql statement

select GUID, Max(amount) as Amount from
     (Select * from memory\m2 as X
     union
     select * from memory\m3 as y) as z")
group by GUID

Both X and Y have 2 columns [GUID, Amount]

May I ask how would I selected from the union?
>>

Select * INTO MEMORY\M4 from memory\m2 as X
union
select * from memory\m3 as y
;
select GUID, Max(amount) as Amount from memory\m4
group by GUID
Image